网站不使用url www

网站不使用url www,url,.htaccess,url-rewriting,Url,.htaccess,Url Rewriting,您好,当我键入http://example.com它工作正常,但当我键入http://www.example.com它显示找不到的页面 什么问题我找不到,我试过了。htaccess重定向也 RewriteEngine On RewriteCond %{HTTP_HOST} ^www.example.com [nc] RewriteRule (.*) example.com/$1 [R=301,L] 它不起作用 如果您要重定向到其他网站,必须在前端指定“http://”,否则Apache it会

您好,当我键入
http://example.com
它工作正常,但当我键入
http://www.example.com
它显示找不到的页面

什么问题我找不到,我试过了。htaccess重定向也

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [nc]
RewriteRule (.*) example.com/$1 [R=301,L]
它不起作用


如果您要重定向到其他网站,必须在前端指定“http://”,否则Apache it会将其解释为服务器上的文件,我们将不胜感激

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

检查apache vhost文件中是否设置了www别名

<VirtualHost *>
..
ServerName www.example.com
ServerAlias example.com
...
</VirtualHost>

..
服务器名www.example.com
ServerAlias example.com
...

还记得在每次更改后重新启动Apache。

是否为两个地址都设置了DNS别名?它们是否指向同一IP?根据您的ISP,可能需要一段时间才能对您进行任何更改

您应该使用example.com或.example TLD作为示例URL-这保证您不会在您的URL中实际放置其他人的URLexamples@Gareth-你为什么不编辑它这是servervault.com的问题