Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.

Thanks,

  • 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]