Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

James Male
James Male
6,619 Points

301 redirects

I have built my website and have run it through Woorank and Nibbler and both are mentioning That I have duplicate content...

After looking into this I found out that the cause was that I have no 301 redirects to redirect my www.james-male.co.uk to james-male.co.uk

My question is how do I create a 301 redirect to solve the problem of having duplicate content?

Or have I got the wrong end of the stick entirely? Can someone please shed some light on this one please as it has got me stuck.


  • James

2 Answers

James Male
James Male
6,619 Points

I am assuming this may be the solution:

Redirect 301 www.james-male.co.uk / james-male.co.uk

However am reluctant to try it in case it breaks anything...

James Male
James Male
6,619 Points

The fix is putting the following code in the .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]