1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to configure Apache so multiple domains use the same HTML/PHP files?

Discussion in 'Apache' started by doyoulikeourowl, Oct 12, 2012.

  1. #1
    Hi all

    I hope someone can help me with this.

    I have multiple domains which use the same HTML, CSS and PHP code, but display slightly different content. This is easiest to understand if I show you:

    http://www.dublinjobs.ie
    http://www.corkjobs.ie

    As you can see, both websites are practically the same except dublinjobs.ie shows jobs from Dublin, and corkjobs.ie shows jobs from Cork. The difference between the two websites is basically a slightly different SQL select query retrieving different results from a database.

    This is my problem:

    Currently I have a separate directory structure for each website, e.g. /home/dublinjobs.ie/public_html and /home/corkjobs.ie/public_html. Each directory contains their own index.php, members.php, etc., files.

    What I would like to do is to have one directory only, e.g. /home/websites/public_html which is used by ALL domains, so Apache would read index.php from /home/websites/public_html if I went to dublinjobs.ie or corkjobs.ie. (I would then figure out which domain they have visited using PHP in my index.php script, and generate the correct SQL select accordingly).

    Is this possible?

    Any help greatly appreciated.

    Thanks!
     
    Solved! View solution.
    doyoulikeourowl, Oct 12, 2012 IP
  2. #2
    Sure, it is possible. What you are asking is usually called domain name aliasing. You can alias multiple domain names to one same account and have them all point to the same content. Now, the exact procedure on how to do that depends on what kind of software you are using, are you using cpanel, plesk, or something third... are you a on a dedicated server and have root access or not, etc.

    If you are using cPanel for example, you can achieve the doman name aliasing function through option Parked Domains in your cPanel. Once you add additional domain name as alias/parked then some .htaccess tweaking should resolve the issue of recognizing which domain name is exactly accessed, or you can do the same task through your PHP scripts by reading URL requested.

    Cheers!
     
    pr0t0n, Oct 12, 2012 IP
    doyoulikeourowl likes this.
  3. doyoulikeourowl

    doyoulikeourowl Greenhorn

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Thank you!

    I am indeed using cPanel and a dedicated server, so it sounds like your solution would work perfectly for me.

    Thanks again for your help.
     
    doyoulikeourowl, Oct 12, 2012 IP