开发者

How to make 'www' optional in a Hostname Route in Zend?

Let's say I have the domain "example.com" I would like to add a route such as when the URL is "example.com/whatever/follows" it redirects to "http://www.example.com/wh开发者_开发知识库atever/follows" (forwarding the query strings too).

Basically I would like to translate into Zend the following Apache Rewrite rule:

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

How can we do that if possible at all?

Cheers,


I would recommend to keep it as a apache rule, as it is faster and is the correct way to do. WWW is actually a subdomain value not an optional feature and it should not be present, unless you want the subdomain.

Also check the no-www site.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜