Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What redirect code can solve my duplicate homepage?

I've got a problem with a website, and i don't know which code i must use to solve it.

I've run a crawl test, which results in the following structure:

www.domain.com
www.domain.com/ (this is a big problem, because it's duplicate content)
www.domain.com/category
www.domain.com/category/page
www.domain.com/category2
www.domain.com/category2/page
www.domain.com/category3/subcat4/page
etc.

As you can see, the subpages don't have a trailing slash. My question is: What redirect code is the most effective way to solve the duplicate homepage problem? Taken in account, the subpages don't have (so don't need?) a trailing slash.

like image 265
user1125113 Avatar asked Jan 01 '12 13:01

user1125113


1 Answers

You could just force a trailing slash with .htaccess Something global would look like this (quick untested code)

RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301] 

You can ofcourse just specify the root, and not use the (.*).

like image 158
Nanne Avatar answered Nov 07 '22 00:11

Nanne