简体   繁体   English

网站不使用网址www

[英]site not working with url www

hello im having problem with my site when i type http://example.com it works fine but when i type http://www.example.com it displays page cannot be found , 你好我的网站有问题,当我输入http://example.com它工作正常,但当我输入http://www.example.com它显示页面无法找到,

what is the problem i couldnot find , i tried .htaccess redirection also 我找不到的问题是什么,我也试过.htaccess重定向

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

it is not working 它不起作用

any help will be appreciated 任何帮助将不胜感激

If you're redirecting to a different website you have to specify 'http://' at the front, otherwise Apache it will interpret it as a file on the server. 如果您要重定向到其他网站,则必须在前面指定“http://”,否则Apache会将其解释为服务器上的文件。

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

Check that you have the alias for www set in the apache vhost file 检查apache vhost文件中是否有www set的别名

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

Also remember to restart Apache after each change. 还记得每次更改后重启Apache。

Have you set up DNS aliases for both adresses? 您是否为这两个地址设置了DNS别名? Do they point to the same IP? 他们是否指向相同的IP? Depending on your ISP it may take some time before any changes work for you. 根据您的ISP,可能需要一些时间才能为您进行任何更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM