Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

761 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