homepage Welcome to WebmasterWorld Guest from 54.237.153.141
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Google / Google SEO News and Discussion
Forum Library, Charter, Moderators: Robert Charlton & aakk9999 & brotherhood of lan & goodroi

Google SEO News and Discussion Forum

    
Does www resolve matter?
wockawocka




msg:4613412
 8:07 am on Sep 28, 2013 (gmt 0)

I was running a keyword checker for SEO purposes and it popped up with a warning of a duplicate content issue. As in, the website is returning a 200 code for the www and non www version on my site when the www version should be sending back a 301.

Should I 301 the www. version via htaccess.

If so, do I just do it for the homepage or every single one?

Is it even a real issue?

 

lucy24




msg:4613505
 8:12 pm on Sep 28, 2013 (gmt 0)

Should I 301 the www. version via htaccess.

YES. It's a single global RewriteRule containing the element

!^(example\.com)?$

Ordinarily it's the last of your external redirects and the only one that applies to all requests all the time.

Details show up in the /apache/ forum at least once a week multiplied by how long the forum has been in existence so we're looking at several hundred identical threads. You did say htaccess, right?, so no need to worry about IIS equivalent.

mihomes




msg:4613511
 8:36 pm on Sep 28, 2013 (gmt 0)

As Lucy said, definitely YES. If you have both the www and non-www version available then you essentially have a dupe of every page on your site as they are seen as two separate entities.

Choose which version you want to be used and redirect the other to it. If you have a webmaster tools account with Google you can also select which version you prefer in your account for this particular site which should help on top of adding a redirect rule.

There are plenty of reasons to do this, but the main is dupe content. It can also protect you from others linking to your site in your non-preferred version and even competitors from hurting you on purpose if they know the problem exists.

Here is the default coding I use in htaccess to force the www version of all pages :

# BEGIN non-www to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Essentially this says if NOT www then redirect to www.

There are plenty of 'methods' to do this so do your research first before applying one as you may have different needs then above.

wockawocka




msg:4613523
 10:35 pm on Sep 28, 2013 (gmt 0)

Thanks all.

I added the following to my htaccess:

RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

So that my full htaccess file reads

Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . routing.php
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]


The only thing of concern is the website I used to check for 200 response codes is now reporting 301 for all versions on the url (but the site itself loads fine).

It's reporting the example.com as a 301 as well.

[edited by: aakk9999 at 11:02 pm (utc) on Sep 28, 2013]
[edit reason] replaced mysite.com with example.com to prevent auto-linking [/edit]

aakk9999




msg:4613531
 11:07 pm on Sep 28, 2013 (gmt 0)

The only thing of concern is the website I used to check for 200 response codes is now reporting 301 for all versions on the url (but the site itself loads fine).

You can use WebmasterWorld tool to check the response headers:
http://freetools.webmasterworld.com/tools/fetch-header/ [freetools.webmasterworld.com]

Regarding your .htaccess, your routing.php script should also check for www/non-www and return 301 if non-canonical domain is used.

lucy24




msg:4613545
 12:13 am on Sep 29, 2013 (gmt 0)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . routing.php
RewriteCond %{HTTP_HOST} !^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

What does routing.php do? Context makes it look like one of those dreadful built-in CMS rules. If so, it can probably be constrained to requests for pages.

Swap your two rules. Anything that creates an external redirect ([R] flag) normally goes before anything that creates only an internal rewrite ... and OUCH! every rule should end with the [L] flag unless there's a specific reason to omit it.

If "routing.php" is not a CMS rule but something that issues redirects, then you don't need the separate rule looking at HTTP_HOST. Incorporate it into the routing.php code instead. But still include the [L] flag.

ZydoSEO




msg:4613569
 3:40 am on Sep 29, 2013 (gmt 0)

Simply decide whether you prefer URLs "with" www or "without" www. and setup your redirects appropriately.

What you have above essentially say that the non-www is your preferred URL and redirects all requests WITH a www to the non-www version of the URL.

wockawocka




msg:4613585
 6:23 am on Sep 29, 2013 (gmt 0)

Lucy,
Here's my routing.php:

<?
$tmp_url=explode("/",$_SERVER['REQUEST_URI']);
$check = 0;
include($_SERVER['DOCUMENT_ROOT']."/index.php");

?>

(So whatever that does, if it helps to explain it)

I appreciate all your input folks.

wockawocka




msg:4613587
 6:26 am on Sep 29, 2013 (gmt 0)

BTW aakk9999 thank you. I used the above link and it returned 301 for all but the desired non.com

lucy24




msg:4613591
 7:06 am on Sep 29, 2013 (gmt 0)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . routing.php


<?
$tmp_url=explode("/",$_SERVER['REQUEST_URI']);
$check = 0;
include($_SERVER['DOCUMENT_ROOT']."/index.php");
?>

I think my brain must be worn out from spending the last five-plus hours wrestling with the e-book of Lane's Latin Grammar. It insists on reading this rule-and-code pair as

"If there is a request for anything whatsoever that doesn't physically exist, silently show the content of the domain's front page instead."

And I KNOW that can't be right :(

wockawocka




msg:4613592
 7:12 am on Sep 29, 2013 (gmt 0)

That might be a bit of legacy code from the old site Lucy. I'll ask the guy who built the site.

wockawocka




msg:4613958
 11:38 am on Oct 1, 2013 (gmt 0)

Update, since changing the htaccess file to fix the issue my indexed pages have dropped from 5660 to 3420

(based on a Google site:mysite search)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Google / Google SEO News and Discussion
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved