仅在www.example.com上显示apache2站点,默认为http://example.com的apache2页面

访问http://www.wraithnath.com时,我的网站www.wraithnath.com正常工作

但是当我从http://wraithnath.com访问我得到默认的Apache 2页面。

网站上的一些图片不再可以从http://wraithnath.com引用

这一切都工作之前,所以我不知道有什么改变。

我的DNS有一个logging指向@的IP地址,并有一个www的cname。

我的conf看起来像这样:

ServerAdmin *removed* DocumentRoot /var/www/WraithNath ServerName wraithnath.com ServerAlias www.wraithnath.com <Directory /var/www/WraithNath/> AllowOverride All </Directory> 

我还能检查什么来解决这个问题?

谢谢

您可以将其添加到.htaccess中,并在不需要2个虚拟主机的情况下redirect到www

 RewriteEngine On RewriteCond %{HTTP_HOST} ^wraithnath.com RewriteRule (.*)$ http://www.wraithnath.com/$1 [R=301,L] 

按照https://stackoverflow.com/questions/1100343/apache-redirect-from-non-www-to-www使用像下面这样的虚拟主机&#xFF1A;

 <VirtualHost *:80> # Set domain to redirect to www ServerName wraithnath.com Redirect permanent / http://www.wraithnath.com/ </VirtualHost> <VritualHost *:80> # Add directory to this virtual host ServerName www.wraithnath.com <Directory /var/www/WraithNath/> AllowOverride All </Directory> </VirtualHost> 

这通常发生在apache未configuration为从域服务的情况下。 (检查你的拼写!)