Help with mod_rewrite

I have a home / admin folder. This folder has index.php. When I access domain.com/admin/, my mod_rewrite rule redirects index.php to my home folder. I want mod_rewrite to skip the existing folder or files, and a special case for / admin / folder that contains the index.php file.

My rewrite rule is:

 <IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^$ index.html [QSA]
   RewriteRule ^([^.]+)$ $1.html [QSA]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php [QSA,L]
 </IfModule>

      

Thanks.

+1


a source to share


1 answer


Try to change

RewriteCond %{REQUEST_FILENAME} !-f

      

to

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

      

This will skip directories as well as files



Edit: I think this rule is wrong (s):

RewriteRule ^([^.]+)$ $1.html [QSA]

      

Try this instead

RewriteRule (^|/)([^.]+)$ $2.html [QSA]

      

+3


a source







All Articles