how fix rewrite rule conflict
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, url-rewriting, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :I am using following rewrite rule and its working fine :
1) RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)/$ estates1.php?pageNum_Clusterb=$3&estname=$1&location=$2 [L]
but when add second code in my htaccess to use it , the second code not work :
2) RewriteRule ^([^/]*)/([^/]*)/$ estates1zone.php?pageNum_Clusterb=$2&zone=$1 [L]
if first code disable , second code work , but together not working second code .
appear any conflict , Can you guide How can fix it ?
There is a conflict because the first rule matches the same pattern that the second rule matches against. ie. /foo/bar/ is matched by both rules.
Whilst you say the first rule is "working fine", it looks like it might be matching too much due to the optional slashes mid-pattern. It will match URLs of the form /foo/, /foo/bar/ and /foo/bar/baz/ - is that the intention?
The quick fix is to simply reverse these two directives, so the more specific rule (that matches exactly 2 path segments) is first. The "more generic" rule (that matches one, two or three path segments) would then follow.
However, I would also check that the first/original rule is working as intended. eg. Should a request for /foo/ be routed to estates1.php?pageNum_Clusterb=&estname=foo&location=?
Comments
Post a Comment