Reputation: 31
I'm writing a mvc framework in php, and trying to rewrite urls using this pattern:
www.example.com/contact/send/
to read as
www.example.com/index.php?url=contact/send/
So I can explode the $_GET['url'] var and use into the fw to route.
Its working great in almost any case, the only issue is that when I try to use a string that is a folder too, ak 'admin', without a trailing slash, the url exposes the variables.
Like this:
www.example.com/admin/ - OK, the url stays just like that
www.example.com/admin - Heres the problem, the url redirects browser to:
www.example.com/admin/?url=admin
The $_GET['url'] is set and working ok in both cases, but I wish to doesnt expose the 'url=admin'.
Theres any way to do that?
Thanks!
The .htaccess is:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} -d RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
Upvotes: 0
Views: 500
Reputation: 5774
I think you are missing a ! :
RewriteCond %{REQUEST_FILENAME} !-d
You want to rewrite when it is NOT a directory.
Edit: Or maybe a exception
RewriteCond %{REQUEST_URI} !^/admin/?
Upvotes: 1