7

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

Satish
  • 16,544
  • 29
  • 93
  • 149
Nikki Wilson
  • 71
  • 1
  • 1
  • 3

3 Answers3

11

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]
Satish
  • 16,544
  • 29
  • 93
  • 149
6
RewriteRule ^(.*)index\.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L]
Zeiss
  • 61
  • 1
  • 3
1

You can rewrite '/index.php' through .htaccess like this:

# Remove /index.php from all urls
RewriteRule ^(.+)/index\.php$ /$1 [R=302,L]
CodeWhisperer
  • 1,143
  • 2
  • 19
  • 39