我尝试写一个,如果一个页面与访问的作品重定向仅的http://
,也与 HTTP:// WWW。
。
I try to write a redirect that works if a page is accessed with only http://
and also with http://www.
.
这是我有:
RewriteCond %{REQUEST_URI} ^(.*)$example.com$
这应该工作无论怎样的URL开始,但我想应该尽可能具体。
This should work no matter how the URL begins, but I would like to be as specific as possible.
我已经尝试过这样的事情,但它没有工作:
I already tried something like this, but it didn't work:
RewriteCond %{REQUEST_URI} ^(http://)$^(www.)$example.com$
如何做我必须写一个重写条件适用于一个页面只有的http://
和 HTTP:// WWW
?
使用这样的:
RewriteCond %{REQUEST_URI} ^/?(?:www.)?example.com$ [NC]
注
(?:WWW )?
为您提供了一个可选的 WWW。
组
[NC]
使得比赛不区分大小写
(?:www.)?
gives you an optional www.
group
[NC]
makes the match case-insensitive