Regex 修改重写:重写相互冲突的规则
我想将主页mydomain.com重定向到mydomain.com/index.php?cat=home 以下是我的htacess文件规则:Regex 修改重写:重写相互冲突的规则,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我想将主页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] 当两者都处于活动状态时,我的站点中的每个页面都会被重定向到index.php?cat=home 此htaccess有什么问题?在您的
RewriteRule index.php index.php?cat=home [L]
RewriteRule (.*)-live-streaming-online.html index.php?cat=$1 [L]
当两者都处于活动状态时,我的站点中的每个页面都会被重定向到index.php?cat=home
此htaccess有什么问题?在您的文档\u ROOT/.htaccess文件中有这样的规则:
关键是使用%{THE_REQUEST},它表示Apache收到的原始请求。使用重写规则中的其他URI模式可以根据您的其他规则进行更改。@JonLin您能帮忙吗?在第一条重写规则的末尾添加$。“.”也有特殊含义,请使用“\”instead@Mahakala请澄清你的答案,我试过了/但没有工作尝试:重写规则索引\.php$index.php?cat=home[L]@Mahakala尝试了这一点,但它使第二条规则不起作用它给出了500个内部服务器错误它起作用但不是我想要的我希望url在加载mydomain.com/index.php?cat=home时仍然显示为mydomain.com是的,我的规则不会更改浏览器中的url,因为我在这里没有使用任何R标志。您可能有其他一些规则可以做到这一点。如果您有其他规则,请在问题中发布完整的.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]