Reputation: 23
I'm trying to remove index.php from my subfolder url. so if anyone access www.mysite.com/sub-folder/index.php i want the url to redirect to www.mysite.com/sub-folder/. I've added the following htaccess file in sub-folder, but its not working.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-folder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sub-folder/index.php [L]
</IfModule>
Can anyone help me with this? Thanks
Upvotes: 2
Views: 4040
Reputation: 785286
You can use this .htaccess in /subfolder/.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-folder/
# remove index.php from URLs
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ $1 [L,R=302,NC,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
Upvotes: 4