0

Using the search, I found this code to remove all the .php extension in my shared godaddy hosting account;

    Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

And it worked perfectly, but I want to make it so it rewrite the index.php to only show the base URL and not domain.com/index.

Anyone know how this would be done?

Wastedfun
  • 11
  • 2
  • Yes and I found the original code by searching for it, but needed it altered to make an exception for the index.php file, that I did not know how to do. Sorry if I missed a question that had that specific edit. – Wastedfun Jul 29 '14 at 16:52

1 Answers1

0

You can use:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R,L,NE]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
anubhava
  • 664,788
  • 59
  • 469
  • 547