htaccess to remove exact match of index with no extension

Have it like this:

# stop folder access
Options -Indexes
RewriteEngine On

# force https
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] 

# redirect index.php to /, /foo.php to /foo, /home.php to /, /index to /
RewriteCond %{THE_REQUEST} \s/+index\s [NC,OR]
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index|home|(\S+?))\.(?:php|html)[/\s?] [NC]
RewriteRule ^ /%1%2 [R=301,L,NE]

# make all requests append php ext. ie /page = /page.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

# push all processed requests through index.php just exclude
# the css|images|js|fonts folders
RewriteRule ^(css|images|js|fonts)($|/) - [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [L,QSA]

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top