3

someone knows how can i redirect in the .htaccess this rules bellow ?

http://www.domain.com/index.php to http://domain.com

and

http://www.domain.com to http://domain.com 

many tanks

user2403620
  • 33
  • 1
  • 1
  • 3
  • did not found http://www.domain.com/index.php to http://domain.com... only www to non www, i would like to have this both in only one rule... can you help-me with that Cheesemacfly ? tanks – user2403620 May 22 '13 at 21:02
  • http://stackoverflow.com/questions/4365129/htaccess-remove-index-php-from-url – cheesemacfly May 22 '13 at 21:04

1 Answers1

13

Since I'm guessing index.php is what gets served when you go to your document root, you want to explicitly check that /index.php is what is being requested, and not part of the URI, which it will be once the URL-file mapping pipeline does its thing.

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]

Then the www to non-www:

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220