是否可以设置某种自定义主 DNS 来重新路由 URL?

发布于 2024-07-15 11:12:00 字数 434 浏览 2 评论 0原文

基本上,我现在在家用 PC 上运行的是 WAMP 盒装应用程序之一,这样我就可以编写 PHP 代码并使用 MySQL 数据库。 这一切都很好,但我运行了很多网站,所以现在我有一个名为 /~WEBSITES/ 的文件夹,我将所有内容放入这些 http://localhost/~WEBSITES/domain.com/ -- 我想要的是能够输入 http://local.domain.com/ 进入我的地址栏并让它指向我的本地驱动器,但我不希望每个人都这样, 只有我。

可能的?

注意:我运行的是 Windows XP

Basically what I run now on my home PC is one of these WAMP in a box applications so I can write my PHP code and use a MySQL database. That is all fine, but I run a lot of websites so now I have a folder I've called /~WEBSITES/ where I put everything making the URLs to these http://localhost/~WEBSITES/domain.com/ -- what I'd like is to be able to type http://local.domain.com/ into my address bar and have it point to my local drive, but I don't want this for everyone, just me.

Possible?

NOTE: I've running Windows XP

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无妨# 2024-07-22 11:12:00

您需要设置 使用 Apache 的虚拟主机,并将其与 HardCode 的答案结合起来(设置您的主机文件)。 那应该可以满足您的需要。

作者编辑:很棒的文章,这里是关于做什么的快速说明(至少使用最新版本的 apache2triad 作为您的 WAMP 安装程序)

添加到 C:\APACHE_INSTALL_DIRECTORY\conf\httpd.conf

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs"
    ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain1.com"
    ServerName local.domain1.com
</VirtualHost>
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain2.com"
    ServerName local.domain2.com
</VirtualHost>

:到 C:\Windows\system32\drivers\etc\hosts

127.0.0.1   localhost
127.0.0.1   local.domain1.com
127.0.0.1   local.domain2.com

You'll need to setup virtual hosts with Apache, and combine that with HardCode's answer (setting your hosts file). That should do what you need.

AUTHOR EDIT: Great article, here's the quick notes on what to do (at least with the most recent version of apache2triad as your WAMP installer)

Add to C:\APACHE_INSTALL_DIRECTORY\conf\httpd.conf:

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs"
    ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain1.com"
    ServerName local.domain1.com
</VirtualHost>
<VirtualHost 127.0.0.1>
    DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain2.com"
    ServerName local.domain2.com
</VirtualHost>

Add to C:\Windows\system32\drivers\etc\hosts

127.0.0.1   localhost
127.0.0.1   local.domain1.com
127.0.0.1   local.domain2.com
何其悲哀 2024-07-22 11:12:00

修改 C:\Windows\system32\drivers\etc\ 中名为“hosts”的文本文件

假设您要将 www.mycustomer.com 指向本地主机。 添加地址:

127.0.0.1 www.mycustomer.com

Modify the text file named "hosts" found in C:\Windows\system32\drivers\etc\

Suppose you want to point www.mycustomer.com to your local host. Add in:

127.0.0.1 www.mycustomer.com

來不及說愛妳 2024-07-22 11:12:00

您需要 在 apache 中设置虚拟主机(不是 IIS...哎呀),并将其与 HardCode 的答案结合起来。 那应该可以满足您的需要。

You'll need to setup virtual hosts in apache (not IIS... oops), and combine that with HardCode's answer. That should do what you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文