我想将 mydomain.com 的主页重定向到 mydomain.com/index.php?cat=home
这是我的HTACESS文件规则:
RewriteRule index.php index.php?cat=home [L]
RewriteRule (.*)-live-streaming-online.html index.php?cat=$1 [L]
当两者都处于活动状态时,我网站中的每个页面都将 cat 重定向到 index.php?cat=home
这个 htacess 有什么问题?
在DOCUMENT_ROOT/.htaccess
文件中有这样的规则:
RewriteEngine On
RewriteRule ^(.+?)-live-streaming-online.html$ /index.php?cat=$1 [NC,L,QSA]
RewriteCond %{THE_REQUEST} s/+(index.php)?[s/?] [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ /index.php?cat=home [L]
关键是使用 %{THE_REQUEST}
它代表 Apache 收到的原始请求。其他使用 URI 模式从RewriteRule
可能会根据您的其他规则进行更改。