我的 Web 服务器上安装了 Apache HTTPD。有两个网站,分别属于两个不同的域名。假设example1.com
和example2.com
。有几个重定向,例如:
http://
->https://
http://www
->https://
https://www
->https://
对于每个域。一切正常。
但当你去http://84.xx.xx.xx(服务器 IP 地址)有默认的 Apache 页面 -It works!
我的问题是 - 保留原样可以吗/安全吗?或者应该重定向到example1.com
?或者我应该返回 403?
对此有什么想法吗?
答案1
那么 VHOST 怎么样?
打开Drive:\Folder\apache\conf\extra\httpd-vhosts.conf
然后添加VHOST
<VirtualHost example1.com:80>
ServerName example1.com
ServerAlias www.example1.com
DocumentRoot /htdocs/example1.com
ServerAdmin [email protected]
UseCanonicalName Off
</VirtualHost>
NameVirtualHost example1.com:80
<VirtualHost 84.xx.xx.xx:80>
ServerName 84.xx.xx.xx
Redirect 403 /
ErrorDocument 403 "Sorry, direct IP access not allowed."
DocumentRoot /usr/local/apache/htdocs
ServerAdmin [email protected]
UseCanonicalName Off
UserDir disabled
</VirtualHost>
<VirtualHost example2.com:80>
ServerName example2.com
ServerAlias www.example2.com
DocumentRoot /htdocs/example2.com
ServerAdmin [email protected]
UseCanonicalName Off
</VirtualHost>
NameVirtualHost example2.com:80
<VirtualHost 84.xx.xx.xx:80>
ServerName 84.xx.xx.xx
Redirect 403 /
ErrorDocument 403 "Sorry, direct IP access not allowed."
DocumentRoot /usr/local/apache/htdocs
ServerAdmin [email protected]
UseCanonicalName Off
UserDir disabled
</VirtualHost>