views:

25

answers:

1

Hi ALl

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.

+1  A: 

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]
Greg
It does not skip if i type host/admin. I need it to skip since i have index.php in the folder.
shuxer
I tried RewriteCond %{REQUEST_FILENAME} !-d but no help
shuxer
Thanks Greg, it worked, but i got new issue after that, i might have host/admin/pages/add then i have to redirect this url to host/admin/index.php . But now it redirects it to host/index.ph instead of host/admin/index.php
shuxer