taras
taras

Reputation: 2263

Help with mod_rewrite

I have folder home/admin. In this folder there is index.php. When i access to domain.com/admin/ my mod_rewrite rule redirects it my index.php in the home folder. I want mod_rewrite to skip existing folder or files, and special case for /admin/ folder, which contains 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.

Upvotes: 1

Views: 119

Answers (1)

Greg
Greg

Reputation: 321578

Try changing

RewriteCond %{REQUEST_FILENAME} !-f

to

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

This will skip directories as well as files

Edit: I think it's this rule that's going wrong (as well):

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

Try this instead

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

Upvotes: 3

Related Questions