Hello everybody, I have canonical issue in my website. I want to redirect "ruraltraveller.com" and "www.ruraltraveller.com/index.php" to "www.ruraltraveller.com" so please suggest me how I will do this using .htaccess. If possible please give me code snippet for that as well. Thanks in advance.

Recommended Answers

This should do it ... it's untested though.

 # Force everyone to use www.example.com
 RewriteCond        %{HTTP_HOST}    !^www.example.com$              [NC] 
 RewriteRule        ^(.*)$      http://www.example.com/$1       [R=301,L] 

 RewriteRule ^index.php$ http://www.example.com [R=301,L]
Jump to Post

All 3 Replies

This should do it ... it's untested though.

 # Force everyone to use www.example.com
 RewriteCond        %{HTTP_HOST}    !^www.example.com$              [NC] 
 RewriteRule        ^(.*)$      http://www.example.com/$1       [R=301,L] 

 RewriteRule ^index.php$ http://www.example.com [R=301,L]

This is the code...
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>

Thnx...:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.