|
|
#1
| ||||
| ||||
|
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:
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:
.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. |
|
#2
| ||||
| ||||
|
I have just received a request to clarify my statement: Quote:
So what does Google do?
Some background reading - Webmasterworld - you need to be logged in to a free account before you can access - 301 redirects www and non-www |
|
#3
| |||
| |||
|
You wrote: Quote:
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) |
|
#4
| ||||
| ||||
| 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. |
|
#5
| |||
| |||
| - 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. |
|
#6
| ||||
| ||||
| Quote:
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. |
|
#7
| |||
| |||
|
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.
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 301 redirects | T2DMan | 9 | 25th May 09 06:58 AM | |
| ASP 301 redirects | T2DMan | 1 | 4th Aug 06 02:25 PM | |
| index.php to root redirects | T2DMan | 0 | 1st Jun 06 12:37 PM | |