【问题标题】:Apache Server Unable to host multiple domain on single Public IP Error : "Not Found The requested URL / was not found on this server."Apache 服务器无法在单个公共 IP 上托管多个域错误:“未找到请求的 URL / 未在此服务器上找到。”
【发布时间】:2017-06-09 08:01:06
【问题描述】:

Apache 服务器无法在 Windows Server 2016 上运行的单个公共 IP 上托管多个域

错误:“未找到请求的 URL / 在此服务器上未找到。” 404 未找到

目前的进展:

1) 编辑 Windows 主机文件 "C:\Windows\System32\drivers\etc\hosts": 到下面

127.0.0.1       localhost
::1             localhost
127.0.0.1       koffeeroasters.com

2)apache的httpd.conf文件的改动如下

改变了

#Include conf/extra/httpd-vhosts.conf

Include conf/extra/httpd-vhosts.conf

也变了

#LoadModule rewrite_module modules/mod_rewrite.so

LoadModule rewrite_module modules/mod_rewrite.so

并在文件末尾添加以下内容

# Tells Apache to identify which site by name
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wampstack/apache2/htdocs"
</VirtualHost> 
# Tells Apache to serve Client 1's pages to "client1.localhost"
# Duplicate and modify this block to add another client
<VirtualHost 127.0.0.1>
# The name to respond to
ServerName koffeeroasters.com
ServerAlias www.koffeeroasters.com
# Folder where the files live
DocumentRoot "C:/wampstack/apache2/htdocs/koffeeroasters.com/"
# A few helpful settings...
<Directory "C:/wampstack/apache2/htdocs/koffeeroasters.com/">

Order Allow,Deny
Allow from all
# Enables .htaccess files for this site
AllowOverride All
</Directory>
# Apache will look for these two files, in this order, if no file is specified in the URL
DirectoryIndex index.html index.php
</VirtualHost>

其他详情

我在 bitnami wampstack 上使用 apache 服务器。

在服务器浏览器中键入地址“koffeeroasters.com”时,站点可用。

我不知道解决方案的原因(参考 apache 文档“https://httpd.apache.org/docs/2.4/vhosts/examples.html”):

注意: 在 Apache 服务器上创建虚拟主机配置不会神奇地导致为这些主机名创建 DNS 条目。您必须拥有 DNS 中的名称,解析为您的 IP 地址,否则其他人将无法看到您的网站。您可以将条目放在 hosts 文件中以进行本地测试,但这仅适用于具有这些 hosts 条目的机器。

非常感谢。所有帮助表示赞赏。

【问题讨论】:

    标签: apache dns wamp multiple-domains windows-server-2016


    【解决方案1】:

    尝试改变这个:

    <VirtualHost 127.0.0.1>
    

    <VirtualHost *:80>
    

    这意味着允许任何其他 IP 在端口 80 上连接,这应该可以帮助您。尝试匹配本地主机可能比您需要的更多,除非您是面向公众的服务器,在这种情况下您不会想要这样做。

    【讨论】:

    • 堆栈溢出说不谢谢,但我感激不尽。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-28
    • 2019-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多