开发者

.htaccess simplification / better solution?

I'm trying to tweak some rewrites in an .htaccess file but my regexp/mod_rewrite knowledge is thin!

We have primarydomain.com and secondarydomain.co.uk, and we want to rewrite anything and everything to www.primarydomain.com

At present I'm doing this:

RewriteCond %{HTTP_HOST} ^secondarydomain.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondarydomain.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^primarydomain.com$
RewriteRule (.*)$ http://www.primarydomain.com/$1 [R=301,L]

.. but I'm sure there is a better way?? Is there a rule that would rewrite a开发者_如何学Gony host that's not www.primarydomain.com? I tried playing about with the not operator (!) and managed to cause a redirect loop so don't want to do that :/

Any help appreciated! Ben


Ok, Found it myself:

RewriteEngine On
RewriteRule ^(.*)$ http://www.primarydomain.com/ [R=301,L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜