mardi 4 juillet 2017

make .htaccess to prevent navigating to directories

I have this .htaccess

DirectorySlash On
RewriteEngine On

RewriteRule /?\.htaccess$ - [F,L]

# Remove trailing slash
RewriteRule ^(.*)/$ /project/$1 [R,L]

# Map every link to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/project/index.php.*$
RewriteRule ^(.*)$ /project/index.php?___MYROUTER=$1 [QSA,END]

but when I'm navigating to one of directories next to my .htaccess file like css folder in browser, with this address:

http://localhost/project/css

then my address will be changes to:

http://localhost/project/css?___MYROUTER=css&___MYROUTER=css&___MYROUTER=css&___MYROUTER=css&___MYROUTER=css&___MYROUTER=css&___MYROUTER=css&___MYROUTER=css&___MYROUTER=css&___MYROUTER=css

and in firefox this is the result:

The page isn’t redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept cookies.

but other addresses those are not pointing to an existing directory, will be ok like:

http://localhost/project/mycontroller

this address is ok and will not be changed to anything else

What is the problem with my .htaccess?




Aucun commentaire:

Enregistrer un commentaire