homepage Welcome to WebmasterWorld Guest from 54.166.122.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Multiple 301 Redirect to Subdomian
Please help : 301 Redirect to Subdomian same url structure
pemba76

5+ Year Member



 
Msg#: 4541229 posted 7:06 am on Feb 1, 2013 (gmt 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.

 

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4541229 posted 10:06 am on Feb 1, 2013 (gmt 0)

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?

pemba76

5+ Year Member



 
Msg#: 4541229 posted 4:07 pm on Feb 1, 2013 (gmt 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/

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved