如何重定向所有网址为WWW。子域 [英] How to redirect all urls to a www. subdomain

查看:164
本文介绍了如何重定向所有网址为WWW。子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这有重写我的.htaccess:

I've got this rewrite in my .htaccess:

RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^domain.com/$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

这对于domain.com工作正常,但不能与/后的东西重定向U​​RL

Which works fine for domain.com but doesn't redirect the URL with something after the /

(domain.com/something.php应该重定向到www.domain.com/something.php~~V)

(domain.com/something.php should redirect to www.domain.com/something.php)

如何才能做到这一点?

在此先感谢!

推荐答案

看看

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

这篇关于如何重定向所有网址为WWW。子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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