Forum Moderators: phranque
My client has an old site which they decided to expand into a new site.
I want to redirect all the articles of the old site to the new site, but then set up a catch-all 301 redirect to go to a subdomain on the new site.
Sorta like this;
DenverOldSite.com/article1.html should go to NewSite.com/article1.html
but anything outside of the articles should be caught and go to the home page of Denver.NewSite.com.
So far I have this in the .htaccess
## CATCH-ALL REDIRECT##
RewriteCond %{HTTP_HOST} ^(oldsite¦www.oldsite) [NC]
RewriteRule ^(.*)$ http://denver.newsite.com/$1 [R=301,L]
redirect 301 /article1.html http://www.newsite.com/article1.html
So the catch-all redirect is working, but the specific page redirect does not go to the new site, but automatically goes to the subdomain article1.html page.
Is it possible to redirect like this?
I appreciate any advice anyone can give me on this.
[edited by: jdMorgan at 12:05 am (utc) on June 17, 2009]
[edit reason] de-linked [/edit]
Options +FollowSymlinks
RewriteEngine On
## SEND ARTICLES BACK TO ROOT DOMAIN ##
RewriteRule ^articles/(.*)$ http://www.newsite.com/articles/$1 [R=301,L]
RewriteRule ^/articles/article1.html(.*)$ http://www.newsite.com/article/article1.html$1 [R=301,L]
## CATCH-ALL REDIRECT ##
RewriteCond %{HTTP_HOST} ^(oldsiteaustin¦www.oldsiteaustin) [NC]
RewriteRule ^(.*)$ http://austin.newsite.com/$1 [R=301,L]
[edited by: jdMorgan at 5:52 pm (utc) on June 18, 2009]
[edit reason] De-linked. [/edit]
# Redirect specific article requests (this is only needed
# when the new page's URL-path is not the same as the old)
RewriteRule [b]^art[/b]icles/[i]our-tickle[/i]1.html(.*)$ http://www.newsite.com/article/article1.html$1 [R=301,L]
#
# Redirect all article URL requests to new domain,
# retaining originally-requested article URL-path
RewriteRule ^articles/(.*)$ http://www.newsite.com/articles/$1 [R=301,L]
#
# Redirect non-canonical domain (and old non-article) requests to a subdomain of
# the (new) canonical domain, retaining originally-requested article URL-path
RewriteCond %{HTTP_HOST} [b]^(www\.)?oldsiteaustin\.com[/b] [NC]
RewriteRule ^(.*)$ http://austin.newsite.com/$1 [R=301,L]
I'm not sure what your now-first rule is for actually, since the second rule will cover all cases where the URL-paths (loosely, the "page file names") on the old and new domains are the same. And also, as you had posted it above, it would have never been invoked, since URL-paths seen by RewriteRule in .htaccess do not start with a slash. I corrected that above, but if you don't need the first rule, get rid of it -- That wiil certainly speed things up...
I may have missed your specific question here... Not sure.
Jim