Forum Moderators: phranque

Message Too Old, No Replies

Redirect using .htaccess

301 redirect /index.php to http://www.centraldirectory.net/

         

vic_msn

10:59 am on Apr 21, 2006 (gmt 0)

10+ Year Member



Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.net [NC]
RewriteRule ^(.*)$ http://www.example.net/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.shtml\ HTTP/
RewriteRule ^index\.php$ http://www.example.net/ [R=301,L]

i use the above code in .htaccess it redirects example.net to http://www.example.net/
is there a way i can redirect /index.php to http://www.example.net/

[edited by: jdMorgan at 2:34 pm (utc) on April 21, 2006]
[edit reason] Example.net. [/edit]

jdMorgan

2:33 pm on Apr 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The second rule is broken, because "index\.php" should appear in both the RewriteCond and the RewriteRule patterns. You currently show "index\.shtml" in one, and "index\.php" in the other.

Jim

vic_msn

12:26 pm on Apr 22, 2006 (gmt 0)

10+ Year Member



even i if change it to .php it doesn't work

jdMorgan

2:19 pm on Apr 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In case you're missing a space or some other critical charcter, here's the whole thing:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.net [NC]
RewriteRule (.*) http://www.example.net/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ http://www.example.net/ [R=301,L]

I also removed the 'tail' from the pattern in the second RewriteCond, in case you are trying to pass a query string to index.php.

If this does not work, then there is some other problem. Examine your server error logs and server access logs, and describe in detail how you tested, what happened, and include any pertinent information from those log files.

Jim