URL mapping between 2 domains

715 views apache

We have an online service with 3 customers: Autoparts, CarExamples and Cars & More. This is the url structure:

  • example.com/autoparts
  • example.com/carexamples
  • example.com/carsandmore

One of the customers (CarExamples) wants to use their own domain (carexamples.com), but it has to load the content of example.com/carexamples, of course always using the original domain.

That means that:

  • carexamples.com should load example.com/carexamples
  • carexamples.com/about should load example.com/carexamples/about
  • carexamples.com/categories/trucks?p=1 should load example.com/carexamples/categories/trucks?p=1

We are using a LAMP environment (PHP v5.6). The domain example.com is located in /www/example/html in our server.

The current status of this issue is:

  1. Create an A record in the domain's DNS manager console that points to the same server where example.com is being hosted.

  2. Add a virtual host for the custom domain

    <VirtualHost servername:80>
        ServerName carexamples.com
        ServerAlias www.carexamples.com
        DocumentRoot /www/example/html

But this would just load the same content of example.com when opening carexamples.com

It is worth noting that /www/example/html/carexamples is not a directory, it is a rewrite from /www/example/html/store.php?store=carexamples

Any ideas?

answered question

1 Answer


If I understood your post correctly (correct me or clarify if this isn't what you're looking for)

You need a separated vHost for each entry .. You're looking at the wrong directory -- This is an example -- Though it should be self explanatory .. Just add /carexamples to the DocumentRoot

<VirtualHost servername:80>
    ServerName carexamples.com
    ServerAlias www.carexamples.com
    DocumentRoot /www/example/html/carexamples

posted this

Have an answer?


Please login first before posting an answer.