Solved

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

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
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 …

752 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