matthew3r matthew3r - 1 year ago 168
Apache Configuration Question

Subdomain on localhost

I would like to create a registration form which creates subdomains (yet on localhost), but I have got some problem. I know how to create subdomains, writing for example these in vhosts:

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.hleclerc-PC.ingenidev
DocumentRoot "C:/wamp/www/something/"
ServerName localhost
ServerAlias something.localhost
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common

And put this line in hosts: something.localhost

It's working, but what I want is that when I register a new subdomain (for example: other), then when I try to open other.localhost, then it opens the specified folder (../www/other/).
I tried it in vhosts with "ServerName *.localhost", "ServerName localhost", "ServerAlias *.localhost", "ServerAlias localhost", and in hosts " *.localhost" with all of the permutation of these, but neither of these worked for me.
I have thinked about it, that on registration I put a new block in vhosts, with the optimal data, but I don't think it's very safe/feasible/or the best way to do.

Hope someone can help me!

Thanks in advance!

Answer Source

You could try a rewriterule, which converts a subdomain into a folder.

For example, mystuff.localhost becomes localhost/mystuff

otherthing.localhost/some/dir/here becomes localhost/otherthing/some/dir/here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download