Rederecting a 301 from sub domain to main domain

Discussions about Apache mod Rewrite, .htaccess, Use, experiences ... URL Rewriting.

Moderator: Moderators

Rederecting a 301 from sub domain to main domain

Postby Peter77 » Mon Oct 30, 2006 5:29 am

Turns out my highest PR for me, according to Google's Crawl stats page, comes from an old subdomain.

I was doing some searching on this and found a solution that works.

Code: Select all
RewriteCond %{HTTP_HOST} oldsubdomain.x.com [NC]
RewriteRule (.*) http://www.xcom/ [R=301,L]



Anyway, I was wondering if you see any conflicts/concerns with your SEO / rewrite work?

All seems to be working normally. :)


Thanks!
Last edited by Peter77 on Fri May 11, 2007 9:24 pm, edited 3 times in total.
Peter77
phpBB SEO Team
phpBB SEO Team
 
Posts: 532
Joined: Wed May 10, 2006 9:46 am

Advertisement

Postby dcz » Mon Oct 30, 2006 4:43 pm

Well, what you did is almost ok if you put these rewriterules in the oldsubdomain.mysite.com's .htaccess.
A more correct way would be :
Code: Select all
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^oldsubdomain\.mysite\.com$ [NC]
RewriteRule (.*) http://www.mysite.com/ [R=301,L]


You can as well, if possible, just make the oldsubdomain.juarol.com to be linked to the same folder as you main domain (in the root folder) so that the www prefix redirection you already have there will take care of this one as well As long as you are using the negative case :

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



++
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: 21376
Joined: Fri Apr 28, 2006 9:03 pm

Postby Peter77 » Mon Oct 30, 2006 5:11 pm

Great... it works well. So then if I have the old subdomains .htaccess link back to my main, it then wont be necessary to add it to my main .htaccess, right? And Oops, I tottaly missed the backward slash.

Thank you for taking the time to explain to me the correct way. :)
Peter77
phpBB SEO Team
phpBB SEO Team
 
Posts: 532
Joined: Wed May 10, 2006 9:46 am

Postby dcz » Mon Oct 30, 2006 5:33 pm

The one in your main domain will take care of all cases.
If set like I posted, any domain or sub-domain linked to this main domain will be http 301 redirected ;)

++
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: 21376
Joined: Fri Apr 28, 2006 9:03 pm

Postby Peter77 » Mon Oct 30, 2006 6:08 pm

dcz wrote:The one in your main domain will take care of all cases.
If set like I posted, any domain or sub-domain linked to this main domain will be http 301 redirected ;)

++



That's what I wanted to achieve. Thank you very much. :D
Peter77
phpBB SEO Team
phpBB SEO Team
 
Posts: 532
Joined: Wed May 10, 2006 9:46 am


Return to Apache mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 7 guests