htaccess redirect? easy solution?

Silent Hill

Avatar: Silent Hill

2010-01-14 16:56

Anyone got a easy solution to redirect visets from http://yoursite.com to http://www.yoursite.com ? To avoid double index from search engines?

» Quick.Cart v3.x

beholder

Avatar: beholder

2010-01-14 18:37

Good point, Silent Hill. I didn't know this.

Here is your well deserved code:


Create a 
.htaccess file with the below codeit will ensure that all requests coming in to domain.com will get redirected to www.domain.com 
The 
.htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed

Options +FollowSymlinks
RewriteEngine on
rewritecond 
%{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] 

Please REPLACE domain.com and www.newdomain.com with your actual domain name

NoteThis .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.



If the above doesn't work on some servers (you get an error page) then just remove the line with Options +FollowSymlinks from the .htaccess file.

beholder

Avatar: beholder

2010-01-14 18:39

and here you can check the redirect if it works and if it's search engine friendly:
http://www.webconfs.com/redirect-check.php

Silent Hill

Avatar: Silent Hill

2010-01-14 19:44

Ah, that was easy enough. Found this little one for others who don't know how do make this file.
http://www.apluskb.com/scripts/How_do_I_create_an_answer2168.html

thanks marek :)

Back to top
about us | contact