力" WWW"通过的.htaccess
我想给力WWW。在我的网址(如 http://domain.com 变成的 http://www.domain.com )。不过,我不希望它被迫在已经有一个子域网址(例如: http://images.domain.com 一>不应该成为 http://www.images.domain.com )。下面的代码片段,我发现网上确实后者:
I want to force "www." on my URLs (e.g. http://domain.com becomes http://www.domain.com). However, I don't want it forced on URLs that already have a subdomain (e.g. http://images.domain.com should NOT become http://www.images.domain.com). The following snippet I found on the net does the latter:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
我需要什么做的就是这个工作适合我?谢谢你。
What do I need to do to get this to work for me? Thanks.
简单 下面力WWW的规则,除了子域。
Simple The rules below force www, except for subdomains.
RewriteCond %{HTTP_HOST} =name.domain [NC]
RewriteRule ^(.*)$ http://www.name.domain/$1 [R=301,L]
编辑和贴吧,重启apache。
Edit and paste it, restart apache.
说明:
的RewriteCond%{HTTP_HOST} = name.domain [NC]
匹配,只有当有人类型name.domain(域名)。
RewriteCond %{HTTP_HOST} =name.domain [NC]
match only when someone types name.domain (your domain name).
在类型subdomain.name.domain的的RewriteCond是假的,而不是重定向。你明白? 在规则你previously贴出你是匹配的!(不)^(由年初)www和subdomain.name.domain满意的RewriteCond是你不想要的东西。 :)
When types subdomain.name.domain the RewriteCond is false and not redirect. You understand? In rule that you previously posted you was matching for !(not)^(beginning by)www and subdomain.name.domain satisfied RewriteCond and is what you don't want. :)