Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-04
3
Medium Priority
?
358 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 1000 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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 …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

916 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