我正在生产服务器上设置一个小型网站。 虽然我们正在最后确定最终域的所有设置,但是我们已经将其设置在dev.domain.com上,以便我们的访问者在访问www.domain.com或domain.com时看不到可能有问题的网站。 我通过指定一个虚拟主机来捕获dev.domain.com与“真实”站点的文档,并创build一个新的站点与虚拟主机捕获www.domain.com和domain.com,与documentroot指向一个目录parallell到“真实”的网站,只包含一个index.html。 这个网站会显示访问者有关网站重build的消息。
这些是网站configuration文件:
# dev.domain.com <VirtualHost *:80> ServerAdmin [email protected] ServerName dev.domain.com DirectoryIndex index.html DocumentRoot /var/www/www.domain.com/htdocs/ ScriptAlias /cgi-bin/ /var/www/www.domain.com/cgi-bin/ <Location /cgi-bin> Options +ExecCGI </Location> ErrorLog /var/log/apache2/www.domain.com/error.log CustomLog /var/log/apache2/www.domain.com/access.log combined </VirtualHost> # a-notice-site <VirtualHost *:80> ServerAdmin [email protected] ServerName www.domain.com ServerAlias domain.com DirectoryIndex index.html DocumentRoot /var/www/notice-site/htdocs/ ScriptAlias /cgi-bin/ /var/www/www.domain.com/cgi-bin/ <Location /cgi-bin> Options +ExecCGI </Location> ErrorLog /var/log/apache2/www.domain.com/error.log CustomLog /var/log/apache2/www.domain.com/access.log combined </VirtualHost>
所以,我的问题是这样的 :inputwww.domain.com,www.domain.com。 甚至domain.com。,我到达通知网站就好了,但是当访问只是domain.com(没有尾随点)我的浏览器地址栏告诉我,我已经路由到www.domain.com/notice-site/ htdocs,我得到了一个404,没有findurl。 访问开发网站完美的作品。
我有一个小的预感,这与我设置虚拟主机的方式有关,但可惜我无法弄清楚为什么会导致这种效果。 有没有人听说过类似的东西或可能导致什么?
apache2ctl -S给出:
VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost default server www.domain.com (/etc/apache2/sites-enabled/a-notice-site:4) port 80 namevhost www.domain.com (/etc/apache2/sites-enabled/a-notice-site:4) port 80 namevhost dev.domain.com (/etc/apache2/sites-enabled/dev.domain.com:4) Syntax OK
这些configuration看起来像他们应该工作,你打击某种浏览器问题? 也许你正在使用的浏览器是自动把www的前面的domain.com? 你能清除你的浏览器caching,然后再试一次吗? 确保你没有按[Ctrl] + [Enter]或类似的东西。