Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

www redirect


Guest

Recommended Posts

Hi,

 

Google has a lot of my pages indexed from the non-www version of my site http://easydirectshopping.com - so I would like to force redirects to that one in .htaccess so the www version doesnt get used.

 

Would this code work ok?

 

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^easydirectshopping\.com
RewriteRule (.*) [url="http://easydirectshopping.com/$1"]http://easydirectshopping.com/$1[/url] [R=301,L]

Link to comment
Share on other sites

Oh it does matter - a LOT!

 

If you allow both versions - Google will apply a "duplicate content" penalty and kill your PageRank dead.

Link to comment
Share on other sites

Oh it does matter - a LOT!

 

If you allow both versions - Google will apply a "duplicate content" penalty and kill your PageRank dead.

 

try

 

Options +FollowSymLinks 
RewriteEngine on

# Instead of remapping everything that isn't www, this only remaps requests with no prefix at all
RewriteCond %{HTTP_HOST} =yoursite321.com [NC]
RewriteRule ^ http://www.yoursite321.com%{REQUEST_URI} [R,L]

 

So it keeps subdomains working (in case you're using them).

Link to comment
Share on other sites

I guess I might be confused. You said you DON'T want to use the www. version?

 

Google has a lot of my pages indexed from the non-www version of my site http://easydirectshopping.com - so I would like to force redirects to that one in .htaccess so the www version doesnt get used.

 

I go the other way and try to point everyone to the www. .

 

In which case, Enigma1 has a good solution.

 

I have been using this.

RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
RewriteRule (.*) [url="http://www.mydomain.com/$1"]http://www.mydomain.com/$1[/url] [R=301,L]

 

If you still want to rewrite to http://mydomain.com , then this should work.

RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [NC]
RewriteRule (.*) [url="http://mydomain.com/$1"]http://mydomain.com/$1[/url] [R=301,L]

 

Hopefully.

Link to comment
Share on other sites

yeah thanks mate, i used the first one i posted and it works fine. For some reason google only shows a few links from the www version of my site, but 4 pages of entries for the non www one.

 

They were supposed to fix concatenation issues but so far they haven't - so i just wanted to stick to the one they had indexed most. My site has 355 hits from googlebot in just 5 days on the non www so don't want to lose all that lovely indexing lol

Link to comment
Share on other sites

yeah thanks mate, i used the first one i posted and it works fine. For some reason google only shows a few links from the www version of my site, but 4 pages of entries for the non www one.

 

They were supposed to fix concatenation issues but so far they haven't - so i just wanted to stick to the one they had indexed most. My site has 355 hits from googlebot in just 5 days on the non www so don't want to lose all that lovely indexing lol

 

 

Glad it's working.

 

Just some more information. The way I understand it, google will straighten out the links eventually. That's what the 301 part of the redirect tells it. So, you don't loose the indexing. It's still there. When the google spider next crawls your site it will note the change and correct. Now, I could be all wet on this. If I am, I hope someone will correct me.

 

The reason I go the other way is because most of the user public will invariably put the www in front and don't recognize 'real' links unless they have the www in front. And, when I sell and set up SSL certificates, I always do them with the full URI. Basically just a habit there. But, things stay a bit more comfortable for the customers.

 

Personally, I hate the www. ;)

Link to comment
Share on other sites

Well, I think of www as like calling me "human being Scott Phillips" - jeez I know im one of them, so its a common denominator and should cancel out.

 

So if url's are meant to be unique, it makes no sense to tag them all with www cos thats a common denominator too - and pointless. Like "Office worker ted smith - meet office worker bill higgins" - it doesnt happen cos its stating the obvious.

 

Just my 2c worth lol

Link to comment
Share on other sites

enigma, I will use the ine you posted in the case that it will update when crawled, of course the bots will get redirected too without caring, and they will all be www - cool.

Link to comment
Share on other sites

  • 4 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...