.htaccess redirect index.php to /
22,306
Solution 1
Try, It works for me! Make sure your have AllowOverride All
set in httpd.conf
RewriteEngine On
RewriteCond %{REQUEST_URI} index\.php
RewriteRule ^(.*)index\.php$ /$1/ [R=301,L]
There is a regex issue in your rules, I have modified 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]
Solution 2
RewriteRule ^(.*)index\.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L]
Solution 3
You can rewrite '/index.php' through .htaccess like this:
# Remove /index.php from all urls
RewriteRule ^(.+)/index\.php$ /$1 [R=302,L]
Author by
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
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} ^[A-Z]{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 still shows
-
Admin over 11 yearsnope. could browsers always show the index.php and not redirect to just the domain?
-
Satish over 11 yearsCan you post your .htaccess file.
-
Qullbrune over 9 yearsthe redirect is working, but also adding an trailing slash, the result is example.com// instead of example.com