Time2Dine.co.nz is Online Restaurant Booking
 
 New Zealand Restaurants Forum
Restaurant Forum | Contact Time2Dine | Book Online & Save | About Time2Dine

Go Back   New Zealand Restaurants & Food Forum > Search Engine Optimisation > Google
Register

Reply
 
LinkBack Thread Tools
  #1  
Old 26th May 05, 06:56 PM
T2DMan's Avatar
Administrator
 
Join Date: Apr 2004
Location: Auckland, New Zealand
Posts: 7,840
T2DMan is on a distinguished road
Question non www to www 301 redirects

With SEO, you need to make sure that you only have one domain with the content of your site. All other domains need to have 301 redirects to the initial domain. Therefore all non www should be redirected to the www versions of the domains.

ie the url in your address bar should change from:


  • http://domain.com to http://www.domain.com.
All url's inside the domain should redirect to their www equivalent.
  • http://domain.com/widgets.html to redirect to http://www.domain.com/widgets.html
The instruction is added to a file in the root directory of your website named ".htaccess".

Here is a non www to www 301 redirect in ".htaccess".

[PHP]RewriteEngine On

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

[/PHP]



Windows .net / .asp


For details about isapi rewrites, check out http://www.isapirewrite.com/docs/
Please see the following for a free isapi style of rewrites for windows .net - IonicIsapiRewriter.



For a ISAPI rewrite please try out the following - please get back to me if it works, I dont have a windows machine to try it out on.

Add the following rule to your httpd.ini file:
[php][ISAPI_Rewrite]
RewriteCond Host: ^domain.com
RewriteRule (.*) http\://www.domain.com [RP,L]
[/php]

In iss, the R is for 302 redirects/temporary redirects, and the RP for 301 redirects/permanent redirects.

Quote:
The “Set Up Two Sites” In IIS Way
per Matt Cutts blog Basically, it’s what it says it is. You set up two different sites, one for the non-www and one for the www version. Then, for the home directory of the non-www version, set up a redirect to the www version and ensure that it’s a permanent redirect for this resource (301).


.htaccess in inner directories

Now if you have an htaccess file in any one of the inner directories, then you need slight different code in there as well, since the htaccess works by itself, and does not inherit the upper level htaccess files:

Added to the htaccess file in your forums, or the equivalent in your "forum" directory.

[php]RewriteCond %{HTTP_HOST} ^domain.com
RewriteCond %{REQUEST_URI} ^\/forums\/
RewriteRule (.*) http://www.domain.com/forums/$1 [R=301,L]
[/php]


Two domains pointing to same hosting account

I came across a situation where two domains were pointing at the same hosting account. I had to effectively change the url to the proper one if the domain name was the wrong one. By not having the ^ at the start of domain2, I was able to cater for both the non www and www versions of domain2.

[PHP]RewriteCond %{HTTP_HOST} domain2.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
[/PHP]

Hosting the subdomain in a directory of the main site

This subdomain was able to be accessed both via the main website, and with the subdirectory named as the subdomain.

ie both as
http://www.domain.com/forum
and
http://forum.domain.com
/

Obviously this was not appropriate, so used the following .htaccess to remedy it - placed into the htaccess file on the www.domain.com root folder (thanks vBSEO for helping me):

[PHP]RewriteRule ^forum/(.*)$ http://forum.domain.com/$1 [L,R=301][/PHP]

Inside the subdirectory, you need the following added to your .htaccess file
[PHP]RewriteCond %{HTTP_HOST} !^forum.domain.com
RewriteCond %{REQUEST_URI} ^/forum/
RewriteRule (.*) http://forum.domain.com/$1 [R=301,L]
[/php]


Redirecting from https to http on all but certain url's

I obtained a secure server, and my host set it up so that the new ip number was looking into the same files as my normal site. Meant that my whole site could be accessed via https as well as http. Not the best for Google.

[PHP]RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} !paypal\/(.*)$
RewriteRule (.*) http://forum.domain.com/$1 [R=301,L][/PHP]

Now you have to do the same thing to make sure that the named directory can only be accessed via https.

[PHP]RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} paypal\/(.*)$
RewriteRule (.*) https://forum.domain.com/$1 [R=301,L][/PHP]


Strings used in .htaccess

Basically all the items in the php variable $_SERVER

including
REQUEST_FILENAME
REMOTE_ADDR - being the ip address
HTTP_USER_AGENT
REQUEST_URI - the url excluding the query string
HTTP_REFERER - the domain name ie http://www.domain.com
QUERY_STRING - the items starting with ? in the url
SERVER_PORT - the port, especially useful if you want to check whether its via https - being port 443


Matt Cutts has blogged on 301/302 redirects. As of Dec 2005/Jan 2006, there is a new data center that will be seeking to correct 302/www vs non www etc - SEO advice discussing 302 redirects.

More info on another of Matt's posts - SEO advice URL canonicalization 4 Jan 2006

And all index.php need to be redirected to the root of that domain, or directory. For further information please see - Index.php to root redirects

Last edited by T2DMan; 6th Jun 07 at 11:01 AM. Reason: made mention of isapi rewrites.
Reply With Quote
  #2  
Old 17th Aug 05, 07:09 AM
T2DMan's Avatar
Administrator
 
Join Date: Apr 2004
Location: Auckland, New Zealand
Posts: 7,840
T2DMan is on a distinguished road
Default Further discussion about why a redirect is needed

I have just received a request to clarify my statement:
Quote:
With SEO, you need to make sure that you only have one domain with the content of your site. All other domains need to have 301 redirects to the initial domain
Google does not like duplicate content. When there are both www and non www versions of your site able to be accessed, you have duplicate content available to Google.

So what does Google do?

  • You may have some links coming into your site with the www and others with the non www version of your link.
  • You are effectively splitting your Google Page Rank between the two sites (each www and non www is treated as a site in its own right).
  • If you redirect your non www version, then your www has the benefit of both sets of links.
  • According to Google, which version is the best version of a site?
  • If you have built up many links onto the www version, and have that well ranked on Google, you could get a very powerful link onto your non www version. I have seen instances of where Google has then dumped all the rankings of the www version, then because there is only one powerful link into the non www version, not ranked the non www version. That one link has been enough to say to Google that the non www has been more powerful a site for that moment, but not powerful enough to rank it well.
  • Google will in general only rank one of the sites and over time will only cache one version of the site. Therefore, you want to make sure that it has got the version you have been working on.
  • I have seen instances where there are 4 versions of a site available - www, and non www of each .com and .co.nz country version. Google had started to take its cache off the main version and rankings and numbers of visitors to the sites had started to plummet. With redirects of each to one main site www site, the problem was able to be sorted.
  • When Google sees duplicate content, even a paragraph that returns the same 150 characters around the searchphrase, it will show one page, and not show the other page, not even in the 1000 pages that it lists for each search term. It will not just make them first and second for a search term.
Basically, it is not worth it to have duplicate content on your sites. While there may not be issues immediately, in the long run it is not safe, and it is very easily rectified.


Some background reading - Webmasterworld - you need to be logged in to a free account before you can access - 301 redirects www and non-www
Reply With Quote
  #3  
Old 17th Aug 05, 07:54 AM
Negley
Guest
 
Posts: n/a
Default

You wrote:

Quote:
Google does not like duplicate content. When there are both www and non www versions of your site able to be accessed, you have duplicate content available to Google.


By "duplicate content" do you mean 2 versions of the same site, that is, duplicate files residing in separate places? If so, and unless my Web host automatically duplicates my web files and puts them in 2 separate places, wec-usa.org content is only in one spot, and we only have one version. At least I know that I upload my files to just one URL.

(per email personally received from D Negley)
Reply With Quote
  #4  
Old 17th Aug 05, 08:01 AM
T2DMan's Avatar
Administrator
 
Join Date: Apr 2004
Location: Auckland, New Zealand
Posts: 7,840
T2DMan is on a distinguished road
Default What is "Duplicate"

Fact - you can access your website via both

[HTML] http://www.wec-usa.org/ and http://wec-usa.org/[/HTML]

Therefore Google is able to look at both. Each is considered a website, and they have the same content, therefore we can use the word duplicate to describe the situation.

However, duplicate does not mean two indivudual copies of the website stored on the server.

It is the mechanics of the webserver that allows access into one set of files in two different ways. For other people, they can in fact have multiple domains all pointing to the same set of files.

It is essential as part of good housekeeping, that you change the server settings so that if there is access via the non www version, that there is an immediate "permanent redirect" to the www version. ie a 301 redirect rather than a 302 temporary redirect.

In this way, when you type in the non www version, you will immediately see that changed to be the www version.

Last edited by T2DMan; 26th Oct 05 at 05:19 PM.
Reply With Quote
  #5  
Old 14th Jun 06, 10:59 AM
Junior Reviewer
 
Join Date: Jun 2006
Posts: 1
sperez is on a distinguished road
Default www vs non-www issues

- Initially our site was configured solely as site.com and not www.site.com
- Google initially indexed all pages starting with site.com (some http, other https)
- Both https and http versions were accessible on the site.com domain (which I know is not good practice. This also need to be fixed).
- A redirect in the apache config file was put in place from non-www to www for all pages starting with
http://site.com/
- Ex: http://site.com redirects to http://www.site.com
- By error, this was not put in place for pages starting with https://site.com
- Ex: https://site.com does not redirect to https://www.site.com

Result
-------
- Since the pages starting with
https://site.com were not redirected to https://www.site.com, both versions of these are accesible and indexed, creating duplicate content on Google.
- Our home page:
www.site.com is the only page who has a page rank as all other links starting with www were not indexed by Google.

Questions
-----------
- Is the best way to redirect all
https://site.com to http://www.site.com and restict access to https only to those pages that need to be secured?

Any advice or help would be appreciated.

Last edited by T2DMan; 15th Jun 06 at 06:00 PM.
Reply With Quote
  #6  
Old 15th Jun 06, 05:59 PM
T2DMan's Avatar
Administrator
 
Join Date: Apr 2004
Location: Auckland, New Zealand
Posts: 7,840
T2DMan is on a distinguished road
Default

Quote:
Originally Posted by sperez
-
Questions
-----------
- Is the best way to redirect all
https://site.com to http://www.site.com and restict access to https only to those pages that need to be secured?

Any advice or help would be appreciated.
You have hit the nail on the head.

Please note that I mentioned this exact issue in the first post of this thread.

See the information under the following heading: Redirecting from https to http on all but certain url's

It is heaps easier if there is only say one directory to be accessed via https. Then the regular expression details on the htaccess file are simpler.
Reply With Quote
  #7  
Old 29th May 10, 07:38 AM
Junior Reviewer
 
Join Date: May 2010
Location: Summit County Colorado
Posts: 1
ColoradoRealtor is on a distinguished road
Default

This is important with Bing as well. I recently learned that if the non-www URL resolves, thne that is the one that Bing will typically cache, even if most links point to the www. URL.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
301 redirects T2DMan Google 9 25th May 09 06:58 AM
ASP 301 redirects T2DMan Google 1 4th Aug 06 02:25 PM
index.php to root redirects T2DMan Google 0 1st Jun 06 12:37 PM



Powered by: vBulletin Copyright ©2000 -2010, Jelsoft Enterprises Limited.
Search Engine Friendly URLs by vBSEO 3.2.0
© 2010 Time2Dine