Reputation: 23
I'm looking for a way to remove any file name that is index.php from the URL. The main reason I want to try and do this is because I have directories with "index.php" in them. So instead of getting...
http://localhost/members/index/
I am hoping to achieve something more like...
http://localhost/members/
The code below is currently what I have in my .htaccess file.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]
I really appreciate the help and any suggestions! Thank you so much and God bless!
Upvotes: 0
Views: 174
Reputation: 1011
Just use this:
RewriteCond %{THE_REQUEST} ^.*index.php.*
That's it ;)
Upvotes: 0
Reputation: 22592
If all you want to do is 'remove' index.php from your URLs then you just need to ensure Apache knows that index.php can be used as a directory index.
DirectoryIndex index.php
You can put that in your Apache config, VirtualHost or .htaccess file.
Upvotes: 1