topherg
topherg

Reputation: 4293

htaccess RewriteRule redirecting for URL's without trailing slashes

I have this snippet in my .htaccess file to defend against anyone trying to get into the app directory.

RewriteCond %{REQUEST_URI} ^/app.*$
RewriteRule ^(.*[^/])/?$ index.php?r=$1 [L,QSA]

And although it works when I go to http://domain/app/, if I make a request to http://domain/app, it redirects to http://domain/app/?r=app.

Does anyone know what needs to be changed to stop such redirection?

Upvotes: 0

Views: 83

Answers (2)

pmau
pmau

Reputation: 154

Try the DirectorySlash directive that can be use globally or per directory.

http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryslash

Upvotes: 1

ngplayground
ngplayground

Reputation: 21617

try using

[L]

instead of

[L,QSA]

Upvotes: 0

Related Questions