简体   繁体   English

.htaccess重写规则匹配问题

[英].htaccess rewrite rule matching issue

so i've been tasked to make this URL work 所以我受命使这个URL工作

foobar.com/city.homes

and this.. 和这个..

foobar.com/page-2/city.homes

with this rewrite 用这个重写

RewriteRule ^(.*).homes$      search-results.asp?area=$1&proptype=home

so my first try seems, logically enough i think 所以我的第一次尝试似乎很合逻辑

RewriteRule ^page-(.*)/(.*).homes$     search-results.asp?area=$2&proptype=home&page=$1

however, no matter where i put it in .htaccess, its not working the way i'm expecting it to. 但是,无论我将它放在.htaccess中的哪个位置,它都无法按我期望的方式工作。 it never matches the second rule unless i remove the first one. 除非我删除第一个规则,否则它永远不会匹配第二个规则。

Your regex are wrong and are overlapping. 您的正则表达式有误并且重叠。

Have your rules like this: 有这样的规则:

RewriteRule ^page-([0-9])/([^.]+)\.homes$ search-results.asp?area=$2&proptype=home&page=$1 [L,QSA]

RewriteRule ^([^.]+)\.homes$ search-results.asp?area=$2&proptype=home [L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM