Solved

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

Posted on 2011-03-04
3
349 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 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