Welcome to WebmasterWorld Guest from 54.145.85.22

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Multiple 301 Redirect to Subdomian

Please help : 301 Redirect to Subdomian same url structure

     
7:06 am on Feb 1, 2013 (gmt 0)

Junior Member

10+ Year Member

joined:June 15, 2006
posts: 64
votes: 0


The problem here is that by mistake, a few days back, i 301 redirected :
www.example.com/olddata/ to www.example.com/newdata/

Actually its was supposed to be 301 redirected:
www.example.com/olddata/ to subdomain.example.com/newdata/

Now www.example.com/newdata/ has been indexed by SE also.

My requirement is the following together :

1> 301 redirect :
www.example.com/olddata/ to subdomain.example.com/newdata/
2> 301 redirect :
www.example.com/newdata/ to subdomain.example.com/newdata/

I have the following code that works fine for my first need :

RewriteRule ^olddata/$ [subdomain.example.com...] [R=301,L]
RewriteRule newdata/([^/]+)$ [subdomain.example.com...] [R=301,L]
RewriteRule newdata/ common-code-for-newdata-and-olddata-display-content.php

I am not being able to get the second redirect to work. To make matters worse, the URLs for my second redirect is of the same name and structure. Please see the note below to understand the real problem.

Note : The folder for www.example.com and subdomain.example.com is the same. So both main domain and subdomian share same data as well as same .htaccess file.

Please guide.
10:06 am on Feb 1, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13210
votes: 347


I think what you really want is a twist on the domain-name-canonicalization redirect. This one would go something like

RewriteCond %{HTTP_HOST} !^subdomain\.example\.com$
RewriteRule ^(newdata/(optional-more-stuff-here)) http://subdomain.example.com/$1 [R=301,L]

Normally it would be (subdomain\.example\.com)? for "exactly x or exactly nothing" but that doesn't work with subdomains does it?
4:07 pm on Feb 1, 2013 (gmt 0)

Junior Member

10+ Year Member

joined:June 15, 2006
posts: 64
votes: 0


thanks lucy24 for the response.
Well what i simply want is :

1> 301 redirect :
www.example.com/olddata/ to subdomain.example.com/newdata/
2> 301 redirect :
www.example.com/newdata/ to subdomain.example.com/newdata/