在我的PHP应用程序的.htaccess文件中,我使用一个简单的重写来翻译我的URL:
/shop/hats/detroit/至:
index.php?url=/shop/hats/detroit/使用以下重写规则:
# Rule 1
RewriteRule ^(.*)$ /repos/nvp/httpdocs/index.php?url=/$1 [L,QSA]我希望下面的重写也能奏效:
# Rule 2
RewriteRule ^pic/(.*)$ /repos/nvp/httpdocs/get_image.php?pic=$1 [L,QSA]但这两条规则是相互覆盖或相互冲突的。他们各自独立工作,但不是一起工作。如果url以pic/开头使用规则2而不是规则1,我如何使用所有url来使用规则1?
发布于 2018-07-01 07:36:54
这是因为模式(.*)匹配所有uris。为了避免规则重写,您需要重新排序您的规则,并将特定规则放在第一位。
# specific rules
RewriteRule ^pic/(.*)$ /repos/nvp/httpdocs/get_image.php?pic=$1 [L,QSA]
#catch-all rules
RewriteRule ^(.*)$ /repos/nvp/httpdocs/index.php?url=/$1 [L,QSA]https://stackoverflow.com/questions/51103712
复制相似问题