Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple domains using same content
    primarykey
    data
    text
    <p>I have an application which uses a main domain (domain.com) and I want to be able to point other domains to the same content without needing to maintain separate instances of the code. The application is contained with a folder on the main domain and this folder is not accessed by search engines etc so I am not worried about SEO etc. All of the domains will be on the same server running Apache.</p> <p>I would like to ensure that the domain name stays as the user originally typed it rather than redirect to domain.com as the purpose of this is so multiple customers can use the code but with the application branded to them using their colours, logo etc using settings taken from a MySQL database.</p> <p>For example, a user goes to newdomain.com and they see a login form which is a local stored within /home/newdomain/public_html - on successful login they are directed to /folder which contains the application but rather than be directed to newdomain.com/folder which is empty I would like them to be redirected to domain.com/folder (i.e. /home/domain/public_html/folder) but still see newdomain.com/folder in their browser so it is transparent to them.</p> <p>I tried the below <a href="https://stackoverflow.com/a/9521102/1278201">https://stackoverflow.com/a/9521102/1278201</a> using htaccess but it changes the URL to domain.com:</p> <pre><code>Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC] RewriteRule ^ http://www.domain.com/%{REQUEST_URI} [R=301,L] </code></pre> <p>I also found a post which mentioned using Apache config which seemed a better option as I am not concerned about SEO but am not sure if I can use this to only redirect one folder (i.e. don't redirect webroot, just redirect /folder) <a href="https://stackoverflow.com/a/3849129/1278201">https://stackoverflow.com/a/3849129/1278201</a>:</p> <pre><code>NameVirtualHost * &lt;VirtualHost *&gt; ServerName domain.com DocumentRoot /home/domain/public_html/folder &lt;/VirtualHost&gt; &lt;VirtualHost *&gt; ServerName newdomain.com DocumentRoot /home/domain/public_html/folder &lt;/VirtualHost&gt; </code></pre> <p>I also found posts pointing out possible issues with sessions and SSL certificates <a href="https://stackoverflow.com/a/140008/1278201">https://stackoverflow.com/a/140008/1278201</a> both of which are used in the application. I am happy to install a separate SSL certificate per domain but could any of the above redirects "break" sessions? Obvioulsy if someone logs in to newdomain.com/folder and then goes to domain.com/folder they would need to login again but would the fact that domain.com/folder is redirecting to newdomain.com/folder have an impact on session security?</p> <p>What is the best way to achieve the desired outcome?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload