[英].htaccess mod_rewrite rules conflicting
我有以下重写规则:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(css|gif|ico|jpg|js|png|swf|txt)$
RewriteCond %{REQUEST_URI} !^/(Account|Logout|Password|Tags) [NC]
RewriteRule ^([^/]*)$ /index.php?city=$1 [QSA,L]
RewriteCond %{REQUEST_URI} ^/Account [NC]
RewriteRule ^Account /members/account.php [NC,L]
RewriteCond %{REQUEST_URI} ^/Logout [NC]
RewriteRule ^Logout /members/logout.php [NC,L]
RewriteCond %{REQUEST_URI} ^/Password [NC]
RewriteRule ^Password /members/password.php [NC,L]
RewriteCond %{REQUEST_URI} ^/Tags [NC]
RewriteRule ^Tags /members/tags.php [NC,L]
我正在尝试添加另一个条件,以便将其加载为
domain.com/$city/$provider/$name
这是规则:
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /listing.php?city=$1&provider=$2&urlname=$3 [L]
我的问题是此规则与我的索引文件(作为domain.com/$city加载)的规则冲突。
我将不胜感激所有建议。
谢谢!
您的任何规则都没有错。 只是前者涵盖了最后一个方面。 避免此问题的最简单方法是将限制性更强的规则移到更通用的规则之上。 即在这种情况下,将Listing规则放在index.php规则之前。
糟糕,-> listing.php以及-> indexp.php规则仍将循环,因为Rule1在第一遍触发,然后在第二遍则触发Rule2,因为查询字符串是为了规则中的regexp匹配而剥离的; 和“ listing.php
匹配^([^/]*)$
。
如果模式与现有文件不匹配,则仅应匹配^([^/]*)$
。 防止这种情况的方法是将
RewriteCond %{REQUEST_FILENAME} !-f
在index.php规则之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.