本地主机上的子域
我想创建一个注册表格来创建子域(还在本地主机上),但是我遇到了一些问题.我知道如何创建子域,例如在 vhosts 中编写这些:
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
</VirtualHost>
并将这一行放在主机中:
And put this line in hosts:
127.0.0.0 something.localhost
它正在工作,但我想要的是当我注册一个新的子域(例如:other)时,然后当我尝试打开other.localhost时,它会打开指定的文件夹(../www/other/).我在带有ServerName *.localhost"、ServerName localhost"、ServerAlias *.localhost"、ServerAlias localhost"的 vhosts 和带有所有这些排列的主机127.0.0.1 *.localhost"中尝试了它,但是这些都不适合我.我想过,在注册时,我在 vhosts 中放置了一个具有最佳数据的新块,但我认为这不是非常安全/可行/或最好的方法.
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 "127.0.0.1 *.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.
希望有人能帮助我!
提前致谢!
您可以尝试使用 rewriterule,它将子域转换为文件夹.
You could try a rewriterule, which converts a subdomain into a folder.
例如 mystuff.localhost 变成 localhost/mystuff
For example, mystuff.localhost becomes localhost/mystuff
otherthing.localhost/some/dir/here
变成 localhost/otherthing/some/dir/here