Associate domain with website folder

Discussion in 'Installation/Configuration' started by Jemt, Oct 17, 2015.

  1. Jemt

    Jemt Member HowtoForge Supporter


    I have a lot of websites running on the same domain, e.g., project-Y, project-Z, etc.

    All websites run on the same system, allowing me to quickly create new subsites, and upgrade all sites at once, by simply upgrading the CMS for the primary website (

    I now need to be able to associate domains with several of these sites, e.g. =>

    What I need is a "real domain", not just a redirect.

    What are my options ?

    - Thanks in advance : )

    Best regards
    Jimmy Thomsen
  2. splitter

    splitter New Member

    why is a redirect not an option? you can have a redirect but keep the url you want in the url bar, which will probably be the easiest solution.
  3. Jemt

    Jemt Member HowtoForge Supporter

    Splitter: No, a redirect will not let you keep the original URL at the address bar. URL Rewriting would allow something like it, but not across domains.

    What I need is being able to "map" a folder from accout X to a domain on accout Y.
  4. webguyz

    webguyz Active Member HowtoForge Supporter

  5. splitter

    splitter New Member

    Jemt: if mod_proxy is enabled, you should be able to do it with htaccess...
    i'll give an example in the next post (forum won't let me post the example because it thinks it contains links and i don't have enough posts...
    which is what you get for being a lurker :)
  6. splitter

    splitter New Member

    say you have: with your shops: and
    say that you are going to use for shop one and for shop two

    step 1: put all your domains in the same vhost (ie: servername, serveralias, serveralias
    step 2: create the htaccess (next post *sigh*)
    step 3: done

    now, if someone goes to they stay there, if they go to, they go to shop one,
    if they go to they will end up on BUT see in the address bar,
    and same for and shop 2.

    things to take into account:
    - your absolute/relative links have to be adapted for this scenario (using absolute links for will end up changing the address bar, and using relative links is easy to break so pay attention)
    - you have to have mod_proxy enabled and all domains in one vhost
    - if the [L,NE,P] doesn't work, you might try [P,NC,QSA]
  7. splitter

    splitter New Member

    the htaccess;
    Options +FollowSymLinks -MultiViews
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.org$ [NC]
    RewriteRule ^{REQUEST_URI} [L,NE,P]
    RewriteCond %{HTTP_HOST} ^(www\.)?foo\.bar$ [NC]
    RewriteRule ^{REQUEST_URI} [L,NE,P]

    keep in mind there might be an error in it, i'm a bit rusty :) - but i should have been more accurate since it's a rewrite and not a redirect, so technically... yeah, redirects won't do what you want. but it is possible in htaccess.
    another approach might be php, making an index page and having that extract information to just require the right things?

Share This Page