Solved

How do I redirect all requests for a specific subdirectory to a new domain in Apache?

Posted on 2011-03-04
3
345 Views
Last Modified: 2012-05-11
I purchased a new domain name and in the terms of the purchase, once I take possession of the domain, I need to redirect all traffic to a subdirectory path to the sellers primary domain and preserve the path.

This is only temporary for me while we prep our current site to use the new domain, so I also want all other traffic to this new domain to redirect to my current domains root.

I basically want to fork the traffic to two different domains temporarily.

I'm running Apache 2.2 with mod_rewrite enabled and this will be a virtual directory.

For example, I bought www.mynewdomain.com. I will configure a virtual directory to handle this URL.

1. Redirect some traffic to their domain.


2. Redirect all remaining requests to the root of my current domain.


Any traffic not matching the path specified in the first step should just be redirected to http://www.mycurrentdomain.com

Possible? If so, what would the mod_rewrite look like? I've searched for examples, but haven't found a good match for these conditions yet.
0
Comment
Question by:icg_team
3 Comments
 
LVL 6

Expert Comment

by:Patrick Tallarico
ID: 35037703
I would look at the mod_rewrite module for apache
the guide has a section "Move Homedirs to Different Webserver" that looks like it could be ammended to suit your needs.
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
0
 

Author Comment

by:icg_team
ID: 35037733
That is my question... not a solution. I'm looking for how to structure mod_rewrite in my http config file to handle these specific conditions.
0
 
LVL 26

Accepted Solution

by:
arober11 earned 250 total points
ID: 35054473
Hi

The following should do what you ask, just stick the rule in either your new Domains virtual Host definition in the httpd.conf or in your root .htaccess file:

{code}
RewriteEngine On
RewriteRule  /?store/all.products/products(.*)$   http://www.theirprimarydomain.com/store/all.products/products$1  [R=307,L]
{code}

For an explanation see: http://www.experts-exchange.com/A_4043.html

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
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 …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now