Apache Server Unable to host multiple domain on single Public IP Error : "Not Found The requested URL / was not found on this server."

Apache Server Unable to host multiple domain on single Public IP Error : "Not Found The requested URL / was not found on this server."

Apache 服务器无法在 Windows 服务器 2016

上的单个 Public IP 运行 上托管多个域

错误:"Not Found The requested URL / was not found on this server." 404 未找到

目前的进度:

1) 编辑了 Windows hosts 文件 "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 地址,否则其他人将无法看到您的网站。您可以将条目放入主机文件中以进行本地测试,但这只能在具有这些主机条目的计算机上使用。

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

尝试改变这个:

<VirtualHost 127.0.0.1>

<VirtualHost *:80>

这意味着允许任何其他 IP 连接到端口 80,这应该可以让您继续。尝试匹配 localhost 做的比你可能需要的要多,除非你 public 面向服务器,在这种情况下你不会想这样做。