Locking the www in urls

Discussions about SEO Techniques implemented in your sites. Tests, Studies and results analysis.

Moderator: Moderators

Postby sportman1280 » Mon Dec 18, 2006 3:35 am

Code: Select all
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


works great! thanks :-D
sportman1280
phpBB SEO Team
phpBB SEO Team
 
Posts: 283
Joined: Wed Nov 29, 2006 9:11 pm

Advertisement

Postby arch_stanton » Tue Jan 09, 2007 1:30 am

Hi dcz, as you know from another thread, I have had problems with 302 redirects from an old domain making Google think it is seeing duplicate content.

I have made example.org.uk an alias of example.co.uk as you recommended.

To get rid of the dupes for example.co.uk, I have added the following to my .htaccess:

Code: Select all
RewriteCond %{HTTP_HOST} ^example\.co.uk$ [NC]
RewriteRule ^(.*) http://www.example.co.uk/$1 [QSA,L,R=301]


This seems to work fine. And to get rid of example.org.uk, I have added the following:

Code: Select all
RewriteCond %{HTTP_HOST} ^example\.org.uk$ [NC]
RewriteRule ^(.*) http://www.example.co.uk/$1 [QSA,L,R=301]


But of course this doesn't work for www.example.org.uk. What code do I need to stop these dupes?
:
:
:
:
Edit: I have just added the following code:
Code: Select all
RewriteCond %{HTTP_HOST} ^www.example\.org.uk$ [NC]
RewriteRule ^(.*) http://www.example.co.uk/$1 [QSA,L,R=301]


This does appear to work. Will Google now treat them as 301 redirects?
arch_stanton
PR1
PR1
 
Posts: 163
Joined: Wed Oct 04, 2006 9:48 am

Postby dcz » Tue Jan 09, 2007 11:31 am

I suggest to use only this :

Code: Select all
RewriteCond %{HTTP_HOST} !^www.example\.co\.uk$ [NC]
RewriteRule ^(.*) http://www.example.co.uk/$1 [QSA,L,R=301]


So that anything leading to where the -www.example.co.uk domain is installed will be redirected to -http://www.example.co.uk/

Thus example.co.uk and example.org.uk and -wwwexample.org.uk.

And the redirection are HTTP 301, it's easy to check ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby arch_stanton » Tue Jan 09, 2007 12:27 pm

dcz, remember example1 and example2 are slightly different spellings. So won't I need two separate bits of code anyway?
arch_stanton
PR1
PR1
 
Posts: 163
Joined: Wed Oct 04, 2006 9:48 am

Postby dcz » Tue Jan 09, 2007 12:52 pm

Nope, anything being different than -www.example.co.uk will be redirected, thus whatever.com too if it's linked to this folder ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Multiple domains www. redirection

Postby jolin » Thu Jan 18, 2007 12:33 am

I have a problem. I have a few domains configured on my apache so I can't use a particular domain in the .htaccess rewrite rule!

How do I write the following code to grab the domain name or to just redirect any .domain to www.domain.com

Code: Select all
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


(All of these domains point to the same index file and are not seperated into folders so I can't set individual .htaccess files to each domain)

My apache configuration does not allow me to do the header location redirect for some reason, it just don't do any php header location redirect for some reson? so I can't use this method also.
Last edited by jolin on Tue May 15, 2007 4:25 pm, edited 1 time in total.
jolin
 
Posts: 17
Joined: Thu May 04, 2006 2:27 pm

Postby dcz » Thu Jan 18, 2007 1:28 am

What do you want to do ?

Redirect many domains to one or redirect the www prefix for several domains on the same host ?

To redirect all to one, use :
Code: Select all
RewriteCond %{HTTP_HOST} !^www.example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


To redirect each one individually, use :

Code: Select all
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


For each one of them in the roots .htacces ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby jolin » Thu Jan 18, 2007 1:59 am

dcz wrote:What do you want to do ?

Redirect many domains to one or redirect the www prefix for several domains on the same host ?

++


No No, what I mean is I have like 250 domains on this server and I wont write an individual rewrite rule in the .htaccess for each of them.

I want to redirect .any-domain.any-suffix to www.any-domain.any-suffix (add the www. prefix if non exist)

As I have around 250 domains I can't put a particular domain name in the .htaccess page but rather I need it to fetch it from the address or just say redirect .any-domain.any.suffix to www.any-domain.any.suffix

Could that be done in .htaccess?

(Your doing an unbelieveible work on this site :wink: )
Last edited by jolin on Tue May 15, 2007 4:26 pm, edited 1 time in total.
jolin
 
Posts: 17
Joined: Thu May 04, 2006 2:27 pm

Postby esiason14 » Thu Feb 01, 2007 3:52 am

Hi, I'm getting ready to try to install this and I want to make sure my htaccess is correct.

My CURRENT htaccess looks like this:

Code: Select all
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteRule ^players.php/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$ /players.php?$1=$2&$3=$4&$5=$6&$7=$8 [L]
RewriteRule ^players.php/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$ /players.php?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10 [L]
RewriteRule ^historical_fantasy_pts/year/([^.]+)/position/([^.]+)$ historical_fantasy_pts.php?year=$1&position=$2 [L]
RewriteRule ^historical_fantasy_pts/year/([^.]+)/position/([^.]+)week/([^.]+)/$ historical_fantasy_pts.php?year=$1&position=$2&week=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php


So I add the new rules to the end.?? It is in the subfolder phpBB2, so how would I make those changes and then add it. Thanks!!
esiason14
 
Posts: 3
Joined: Wed Jan 31, 2007 6:53 am

Postby arch_stanton » Thu Feb 01, 2007 6:55 am

dcz, I'm still getting supplemental results on most URLs since locking the WWW. As I installed this mod on January 10 (and already had zero dupe), should all the supplementals be gone by February 10?
arch_stanton
PR1
PR1
 
Posts: 163
Joined: Wed Oct 04, 2006 9:48 am

Postby dcz » Thu Feb 01, 2007 10:31 am

@ esiason14

Just implement the Redirection as your very first one.

Because there is no need to have a RewriteRule match if we are going to redirect it after because of the www prefix, this need to be the very first thing checked.

In your case, would be after :

Code: Select all
Options +FollowSymlinks -MultiViews
RewriteEngine on


You'll just have to make sure it is working before you're done with it.

@ arch stanton
Well, supplemental result is not omitted results, Google said it was kind of a second index to put some types of websites in it.
They claim there is the same probability to show up in SERPs, in both indexes, even though it looks like the supplemental index won't be as good as the main one, but.

Anyway, this has nothing to deal with this redirection, just make sure what you've installed is properly working and work on content and backlinks ;)

I'm not sure you' be PR8 by feb 10 though :lol:

When talking about indexing and search engine, could you in the future use more appropriate threads ?

Thx.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby hvactechforum » Sat Apr 07, 2007 12:25 pm

I added the following code to my .htaccess file:
Code: Select all
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]


Then I cleared all cookies and checked with a new browser, when I typed "hvacruniverse.com" into the address bar I was taken to "http://hvacruniverse.com". Should not I have been taken to "http://www.hvacruniverse.com"? Am I doing something wrong?
hvactechforum
 
Posts: 44
Joined: Sat Mar 03, 2007 12:50 am

Postby falkra » Sat Apr 07, 2007 10:29 pm

Hello, it may sound stupid, but if you really added the code you quoted with no modification, it cannot work, you have to replace "example" by "hvacruniverse". :?
Sorry if you already did. :wink:
User avatar
falkra
PR3
PR3
 
Posts: 370
Joined: Sun Mar 11, 2007 12:11 am

Postby hvactechforum » Sat Apr 07, 2007 10:57 pm

falkra wrote:Hello, it may sound stupid, but if you really added the code you quoted with no modification, it cannot work, you have to replace "example" by "hvacruniverse". :?
Sorry if you already did. :wink:


Yahhh...that might quite possibly be the dumbest thing I have ever done. Let me think.........yup, dumbest thing ever! Thanks falkra! After about 483 hours of code, you start to slip up a little... :oops: :roll: :shock:

It's working now!
hvactechforum
 
Posts: 44
Joined: Sat Mar 03, 2007 12:50 am

Postby noworyz » Sun Apr 15, 2007 6:06 pm

ok, I have this in my .htaccess

Code: Select all
Options +FollowSymlinks
RewriteEngine on

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


and it redirects fine when putting in bigskyfans.com.

But, if I put bigskyfans.com/gallery it redirect to www.bigskyfans.comgallery thus not working. What am I missing to have the / after the .com?

Thanks
noworyz
PR0
PR0
 
Posts: 97
Joined: Mon Jan 08, 2007 10:36 pm

PreviousNext

Return to SEO Techniques

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 2 guests