andy
andy

Reputation: 2409

Multiple Domains on server?

I finally found out how to set up subdomains to point to various directories on my server. For instance:

http://helloworld.dev.example.com => /local/www/static/helloworld

Using this:

<VirtualHost *:80>
    VirtualDocumentRoot /local/www/static/%1
    ServerAlias *.dev.localhost
</VirtualHost>

It works and it's awesome but I have a few problems. One is that I want to make an alias on my local machine in my hosts file that points to that servers IP. This is so when I'm at home I can just go to:

hello.dev.myserver

But although it works for my main domain, it doesn't work when I go to that address. I know it's configured correctly because if I go to http://myserver/ I get this.

The requested URL / was not found on this server.

However http://hello.dev.myserver/ does not work. I've got my hostname setup as the domain (obviously different) example.co.uk. Could it be to do with that?

And the second problem I have that I suspect is going to be fixed when the first one is, is how do I host multiple domains? I want to host my friends site.

Upvotes: 0

Views: 223

Answers (2)

NickNo
NickNo

Reputation: 872

I dont know what system you are using, but on Windows I am running an IIS on port 80 and an Apache on port 8080 with multiple wordpress single and multisite (network installs) doin last part now. Code below works

-

#truncated hosts file at c:/windows/system32/drivers/etc/hosts

127.0.0.1 localhost
#must match the 
127.0.0.1 sx.localhost twt.localhost upse.localhost veet.localhost brbox.localhost eunoia.localhost
127.0.0.1 wp.dev

-

everything below is part of the D:\xampp\apache\conf\extra\httpd-vhosts

NameVirtualHost *:8080

<VirtualHost *:8080>
    DocumentRoot "D:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

/this is a working wordpress normal wordpress blog. the abce.localhost must match the hosts file above, just keep adding them one after another, but subdomain multisite (network must always be last)

<VirtualHost *:8080>
    DocumentRoot "D:/xampp/htdocs/ki/abce/wordpress"
    ServerName abce.localhost
    <Directory "D:/xampp/htdocs/ki/abce/wordpress">
    Options Indexes FollowSymLinks ExecCGI Includes
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

/this below is how network subdomain blog that would work if not for 8080 problem

<VirtualHost *:8080>
    DocumentRoot "D:/xampp/htdocs/alllive/wordpress"
    ServerAlias *.wp.dev
    ServerName wp.dev
    <Directory "D:/xampp/htdocs/alllive/wordpress">
    Options Indexes FollowSymLinks ExecCGI Includes
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

-

Upvotes: 1

JohnHoulderUK
JohnHoulderUK

Reputation: 679

All your hosts file does is resolve the address to the IP and then use that. The hello.dev.myserver is not forwarded. As for hosting your friend's site, you will need to set a VirtualHost up with his domain as the ServerAlias and then point an A Record to your site.

Upvotes: 1

Related Questions