重定向到网站如果WWW部分缺失 [英] Redirect to site if WWW part is missing

查看:149
本文介绍了重定向到网站如果WWW部分缺失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上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

这篇关于重定向到网站如果WWW部分缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆