.htaccess redirect index.php to /

I would like to hide the index.php page and just show the domain.

Is this possible with .htaccess?

RewriteRule ^index\.php/?$ / [L,R=301,NC] 

Also tried:

 RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[AZ]{3,9} /index.php HTTP/ RewriteRule ^index.php$ http://example.com/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] 

index.php is still showing

+6
source share
2 answers

Try it, it works for me! Make sure you have AllowOverride All in httpd.conf

 RewriteEngine On RewriteCond %{REQUEST_URI} index\.php RewriteRule ^(.*)index\.php$ /$1/ [R=301,L] 

There is a regex problem in your rules, I changed your rules and it works for me:

 RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} index\.php RewriteRule ^index\.php$ http://example\.com/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index\.php [L] 
+9
source
 RewriteRule ^(.*)index\.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L] 
+3
source

All Articles