i am getting a little problem here. I am utilizing a simple rule to redirect all demands to some script, excepts some folders with static content :
RewriteEngine On RewriteCond $1 !^(templates|css|js|uploads)/(.*)$ RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
More often than not, the redirection is nice and transparent. But when the folder matching the URL is available and when i do not place the last "/", i'll possess a 301 redirect.
Good examples : (the folder gallery does not is available but mods does)
- ht*p://localhost/test/gallery/ -> OK
- ht*p://localhost/test/mods/ -> OK
- ht*p://localhost/test/mods -> 301 redirection to ht*p://localhost/test/mods/?url=mods
I've this issue on all apache2 servers (examined Fedora, Debian, Home windows).
Someone understands how to solve this ? Thanks
This really is because of the [cde] directive, that will carry out the exterior redirection after your rewrite is carried out, that has the unintentional results of taking your added query string by using it.
You are able to turn
DirectorySlash off, but it is not suggested for that reasons referred to within the documentation. The most well-liked option within this situation is most likely to simply perform
DirectorySlash's work for this, redirecting towards the appropriate slash-ended URL before carrying out your rules. Something similar to this above your overall rule should work: