How to add subdomain in .htaccess and force WWW in url
问题 I have the following code to force WWW in url rewriteCond %{HTTP_HOST} !^www.example.com [NC] rewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] I want to add a subdomain max.example and refer to www.example.com/update/max directory If I do not add any rule, max.example.com will redirect to www.example.com/update/max . If I remove force WWW in url it works. But I still need force WWW in url. How to write the rule? Thanks! 回答1: Change your rule to this: RewriteCond %{HTTP_HOST} !^(www|max)