0


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!

2

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Just use this:

RewriteCond %{THE_REQUEST} ^.*index.php.*

That's it ;)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.