News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Remove "index.php" and "www" to prevent duplicate content penalty

Started by miranon, October 04, 2009, 10:32:32 AM

Previous topic - Next topic

miranon

If you want to prevent the duplicate content penalty from Google, and if your webhosting packet allows this (this works only on linux servers with apache mod_rewrite on), you can create a .htaccess file wit the following code:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://yoursite.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]


Replace the "yoursite.com" part with your url and place this file in the root directory of your forum.

About the duplicate content penalty:

Google think that the following urls are different:

http://www.yoursite.com

http://yoursite.com

http://www.yoursite.com/index.php

http://yoursite.com/index.php


If you check it via google webmaster tools, you can see that the index.php and / versions of your forum have duplicate content problem. You can see that also in the search results from google, where often the .index.php and / versions are indexed apart.

The code above redirects the www part and the index.php part of your forum to the / version.  ;)

p.s. maybe this can be moved to the "Tips and Tricks" forum?

Something like that

SMF 2.0 RC2 and later have canonical URL's. This tells search engines where the primary URL is, so you don't get any penalty for duplicate content.

RC2 has been released to charter members, and will be available to everyone else shortly.

JBlaze

Jason Clemons
Former Team Member 2009 - 2012

Ben_S

You would also want to redirect to index.php rather than away from it as by default SMF for it's home links etc uses index.php so you will be wasting resources requesting index.php all the time only to redirect away from there.
Liverpool FC Forum with 14 million+ posts.

miranon

Quote from: Ben_S on October 04, 2009, 01:22:24 PM
You would also want to redirect to index.php rather than away from it as by default SMF for it's home links etc uses index.php so you will be wasting resources requesting index.php all the time only to redirect away from there.

Yes, that is a good point.

P.s. Only the home link is redirected like yoursite.com/index.php -> yoursite.com/

If you have yoursite.com/index.php/board,1.0.html or yoursite.com/index.php/topic,1.0.html etc. they are not redirected.

L'AltroWeb

I've used this in my site:# Remove WWW from url
RewriteCond %{HTTP_HOST} ^www.darkwolf.altervista.org$ [NC]
RewriteRule ^(.*)$ http://darkwolf.altervista.org/$1 [R=301,L]

And work with all links :)

Advertisement: