1,105,633 Community Members

301 redirect in .htaccess

Member Avatar
Borzoi
Posting Whiz
347 posts since Oct 2006
Reputation Points: 24 [?]
Q&As Helped to Solve: 33 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello all,

How would I go about getting my site to redirect any visitor to http://site.com rather than http://www.site.com?

I have searched the forums here and have tried various coding people have provided but none of it seems to work. Could someone maybe post a step by step guide on how to do this including code, where to put the code and server settings to allow it?

Member Avatar
Kraai
Senior Poster
3,937 posts since Feb 2008
Reputation Points: 56 [?]
Q&As Helped to Solve: 96 [?]
Skill Endorsements: 4 [?]
Featured
 
0
 

Hi

If the server is Linux and having Apache Mod-Rewrite moduled enabled, you can create .htaccess file, with the following code:

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

You upload the .htaccess file to your root directory, where your site index file is.

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

I hope it helps, let us know how you'r doing!

Member Avatar
Borzoi
Posting Whiz
347 posts since Oct 2006
Reputation Points: 24 [?]
Q&As Helped to Solve: 33 [?]
Skill Endorsements: 0 [?]
 
0
 

Ah, that's where I've been going wrong. I had the .htaccess file in the folder with all the configurations. Thanks.

Question Answered as of 3 Years Ago by Kraai
Member Avatar
Kraai
Senior Poster
3,937 posts since Feb 2008
Reputation Points: 56 [?]
Q&As Helped to Solve: 96 [?]
Skill Endorsements: 4 [?]
Featured
 
0
 

Good stuff, glad it worked out all right!

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: