Solved

Rewrite Rule from Domain1 to Domain2 with additional redirects for specfic pages

Posted on 2013-12-02
5
342 Views
Last Modified: 2013-12-10
So I have a rewrite to change domain1 to domain2 keeping the page.
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=302,NC,L]

Open in new window


However I have additional redirects in the htaccess file for specific pages to redirect them to other pages.  So what I end up with is the rules stop processing after the domain switch.  Is it easier to set up a virtual host for the domain and redirect from there to the appropriate page on the other domain using rewrite rules or am I just missing something simple in the domain switch rule .. I already tried removing "L" in rule.
0
Comment
Question by:iceman19330
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 78

Accepted Solution

by:
arnold earned 500 total points
ID: 39691643
You could either copy the page redirects to the new domain, or order the redirects such that the page redirects are evaluated before the domain redirect.

Use rewritecond to test for the page if this condition is matched redirect it directly to the newsite with the page you want there.

How long are you planning on maintaining the OLD domain?
0
 

Author Comment

by:iceman19330
ID: 39691686
OLD domain will be maintained for a month or two before the OLD domain comes back, if that makes sense.  I was asked to do this with taking the OLD domain away and then bringing it back later, not my choice.
0
 
LVL 78

Expert Comment

by:arnold
ID: 39691694
I am uncertain of what your requirements are.  You could add to the new domain virtualhost a serveralias directive referencing/including the old domain and point the old domain to the new domains IP.
This mean each domain has its own IP.

Doing this the way you are heading means that whatever the reason for this one month will require cautious a and painstaking attention to detail.

Presumably, the old site is being revamped.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 39691748
Assuming you are stuck with old.domain.com and new.domain.com, then arnold's suggestion of reordering the rules is probably the best way.
# rewrite your pages first
# note the lack of [L] on these rules
RewriteRule ^/?thispage.htm$ /thisotherpage.htm [NC]
RewriteRule ^/?foo.htm$ /bar.htm [NC]

# now push to the new domain
# this can't fire first, even without the L, because it will mangle the URL
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com [NC]
RewriteRule ^/?(.*)$ http://www.domain2.com/$1 [R=302,NC,L]

Open in new window

If you have the option of continuing to use old.domain.com and do the work on new.domain.com, that would be ideal.
0
 

Author Closing Comment

by:iceman19330
ID: 39709859
It worked like a charm!  Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question