开发者

Htaccess to force use WWW for mutlidomain

开发者 https://www.devze.com 2023-01-02 08:24 出处:网络
I found this code to force using www. RewriteEngine On RewriteCond %{HTTP_HOST} !^www.example.com$ RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]

I found this code to force using www.

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

But i have many domain that po开发者_高级运维inted to same directory. So i need a version of this code for multiple domains. It must run on any domain, is it possible ?


This should work:

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]

It will redirect all request without a subdomain to www.domainame.tld.

0

精彩评论

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