重定向到网站如果WWW部分缺失缺失、重定向、部分、网站

2023-09-02 00:54:52 作者:滚滚滚 滚开。╮

在上SO收视几乎是同一个问题的答案我加入这一行的.htaccess

After viewing answer of almost a same question on SO i added this line in .htaccess

的RewriteCond%{HTTP_HOST}!^ WWW 。 [NC] 重写规则^(。*)$ http://www.example.com/ $ 1 [R = 301,L]

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

但它没有工作了这些2箱子

But it did not worked for these 2 cases

example.com example.com/ example.com/index.php

example.com example.com/ example.com/index.php

在其他情况下,成功地重定向到www.example.com / ... 什么是错误的,我的.htaccess?

In other cases it successful redirected to the www.example.com/... What is wrong in my .htaccess ?

其他信息 对于某种未知的原因[我至少]我不能启用PHP错误页,但对于HTML工作得很好而已。

Additional Info For some kind of unknown reason [to me at least] i can not enable ERROR page for PHP, but works fine for HTML only.

推荐答案

如果我理解正确,这是一个DNS问题。尝试添加CNAME记录:

If I understand you correctly this is a dns issue. Try adding a cname record:

CNAME yourdomain.com www.yourdomain.com

CNAME yourdomain.com www.yourdomain.com