I've got a devoted server (apache, php, mysql)

There's a principal domain (let us refer to it as world wide web.domain1.com) that really holds all of the files like every other regular website hosting account. Another domain (refer to it as domain2.com) must toward it, however with hiding.

So domain2.com/filename.php, domain2.com/filename.php/432/r23-gjfdla-fdjslaf/ all have to show the related content of domain1.com's content, However the browser should still show domain2.com rather than domain1.com, and in addition it needs to be noticeable by $_SERVER['HTTP_HOST'] so my server knows which domain was adopted to make contact with the web site.

The reason being I've 2 clients who're inside a partnership, so they want each customer to retain whatever URL they joined for independent presentation but result in the content unilateral without needing to update two sites at the same time.

<VirtualHost *:80>

  DocumentRoot /world wide web/example1

  ServerName world wide web.domain1.com

  ServerAlias world wide web.domain2.com

</VirtualHost>

The thing you need is Virtual Host feature - two virtual hosts pointing to 1 location.

Obviously code from the page ought to be flexible enough to aid that - for instance internal Web addresses, if absolute (with http:// or https:// part), also needs to reflect the alterations. However, you most likely know it.

Just edit the DNS on domain2.com to suggest towards the same nameserver records for domain1.com. As lengthy because the files utilized on your website aren't hard-coded to some specific domain, it'll instantly use hiding.

I've done something much the same for a few small sites run through the same company (one company, two qualities, each using their website). Both of them are on hosting that is shared, however, you should have the ability to do the identical with VirtualHosts - just define two VirtualHosts, each having a separate domain title, but each pointing to the identical document root around the file system:

<VirtualHost *:80>

    ServerName site1.com

    DocumentRoot /srv/world wide web/public_html

</VirtualHost>

<VirtualHost *:80>

    ServerName site2.com

    DocumentRoot /srv/world wide web/public_html

</VirtualHost>

I've index.php within the public_html directory. This inspections $_SERVER['HTTP_HOST'] to look for the domain title that's being used. After that it sets a couple of constants with appropriate directory locations, along with a site flag which is often used when being able to access the database.

I've three sites for static content. The first is shared content that's employed for both domain names, and also the other two are site-specific, which can consist of logos.

The relaxation from the PHP scripts are held outdoors from the document root inside a separate scripts directory. Where necessary, the scripts may use the constants defined in index.php, for items like absolute Web addresses, or any other site-specific information.

/srv/world wide web/



--public_html

  

  --site1

    

    --css

    --images

  

  --site2

    

    --css

    --images

  

  --shared

     

     --css

     --images



--scripts

Should you wanted two separate document roots, just create two separate index.php files, one for every. They are able to then both call exactly the same common codebase (under /srv/world wide web/scripts/, during my situation). Something similar to this:

/srv/world wide web/



--site1

  

  --public_html

     

     --css

     --images



--site2

  

  --public_html

     

     --css

     --images



--scripts

After which:

<VirtualHost *:80>

    ServerName site1.com

    DocumentRoot /srv/world wide web/site1/public_html

</VirtualHost>

<VirtualHost *:80>

    ServerName site2.com

    DocumentRoot /srv/world wide web/site2/public_html

</VirtualHost>

Whenever you say "regular website hosting account", I am presuming a hosting that is shared. If that's the case, rather than while using Virtual host feature, that you might not have access, you have to try the .htaccess method:

There's already an issue about this: .htaccess redirect one domain to a different incliuding specific query string

Hope it assisted. :-)