Subdomains on Apache

Discussion in 'Apache' started by gravious, Feb 2, 2011.

  1. #1
    Hello,

    I'm new to this forums, and I thought it would be a good place to ask.
    I have recently bought a domain, I've also added some subdomains to it.

    Now, my main website: mywebsite.com shows me my apache webserver.
    I've also set up the domain (forum.mywebsite.com) but it also leads to the main page of my apache webserver.

    I was looking around and found out it had to be in a config file (conf/extra/httpd-vhosts.conf)

    But how do I exactly set the forum.mywebsite.com to display the mywebsite.com/forum folder?

    Help is greatly appreciated.
     
    gravious, Feb 2, 2011 IP
  2. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you need to set the document root for the sub-domain to a folder

    <VirtualHost *>
    ServerName subdomain.domain.com
    DocumentRoot /home/httpd/htdocs/subdomain/
    </VirtualHost>
     
    srisen2, Feb 2, 2011 IP
  3. gravious

    gravious Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, my config file is located here: "C:\xampp\apache\conf\extra\httpd-vhosts.conf"
    and my forum folder is located here: "C:\xampp\htdocs\forum"

    How would I then need to use the code?

    <VirtualHost *>
    ServerName forum.mydomain.com
    DocumentRoot ../htdocs/forum/
    </VirtualHost>

    makes my whole website go to the forum folder.
     
    gravious, Feb 2, 2011 IP
  4. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Make sure you have both entries for your subdomain and regular domain in the conf file as

    <VirtualHost xxx.xxx.xxx.xxx>
    ServerName *.yourdomain.com
    ServerAlias yourdomain.com
    DocumentRoot /home/rootdir #Directory where Scritpting files are located.
    ErrorLog logs/error_log #Error are recorded in error_log file located /var/logs/httpd
    CustomLog logs/visit_log combined # URL visit information recorded in visit_log file located /var/logs/httpd
    </VirtualHost>

    <VirtualHost xxx.xxx.xxx.xxx>
    ServerName subdomain.youydomain.com
    ServerAlias subdomain.youydomain.com
    DocumentRoot /home/rootdir/subdomain
    ErrorLog logs/error_log
    CustomLog logs/visit_log
    </VirtualHost>
     
    srisen2, Feb 3, 2011 IP
  5. gopkris2000

    gopkris2000 Peon

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The problem is your domain A record. Please check with your resolving domain A record and apache configuration.
     
    gopkris2000, Feb 3, 2011 IP