|
|
Question : Regular expression problem while URL rewriting within .htaccess
|
|
Hi,
I'm having some problems rewriting some URL's in my .htaccess files. I want to rewrite everything to one php file, however the following doesn't work for some reason. (The .htaccess file is in the root)
URL: www.mysite.dev/a/b/c/ RewriteRule ^(.*)$ page.php?r=$1 [L] page.php => $_GET['r'] = 'page.php' UNEXPECTED ?????
Yet this does work:
URL: www.mysite.dev/a/b/c/ RewriteRule ^a/(.*)$ page.php?r=$1 [L] page.php => $_GET['r'] = 'b/c' - EXPECTED
Is there a reason why its not working when your regular expression matches the whole path?
Any help would be greatly appreciated as I'm stumped!!
Thanks!
|
Answer : Regular expression problem while URL rewriting within .htaccess
|
|
Yes, because page.php also matches. You can try:
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ page.php?r=$1 [L] or RewriteRule ^(.*/.*)$ page.php?r=$1 [L]
|
|
|
|