I have a site using Apache rewrite module. The problem is that I’m using the RewriteRule like this:
RewriteRule ^([^/]+)/?$ /index.php?p1=$1 [L]
I need to match all the characters except “/”, but it doesn’t work. It counter an error “The requested URL was not found on this server.”
it work with this rule:
RewriteRule ^([^/\.]+)/?$ /index.php?p1=$1 [L]
but this rule will not match the “dot”, so whenever the url have the “dot” it will counter the same as above.
Please help
The reason that isn’t working is because there is an internal redirect loop, let’s say you are getting a request
/zoo:zoo(no leading slash here) matches^([^/]+)/?$and the url gets rewritten to/index.php?p1=zoozooand/index.phpare different so it gets internally redirected, and the rules are applied again, leading slash strippedindex.phpmatches^([^/]+)/?$, gets rewritten to/index.php?p1=index.phpindex.phpand/index.phpare different, so internal redirect againOne way you can stop the loop is to change the rule to:
So that
index.phpwould matchindex.php(no leading slash), but a better way would be to add some rewrite conditions:In front of the rewrite rule.