本地主机上的子域 [英] Subdomain on localhost

查看:35
本文介绍了本地主机上的子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个注册表格来创建子域(还在本地主机上),但是我遇到了一些问题.我知道如何创建子域,例如在 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

这篇关于本地主机上的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆