Do not use the rewrite mechanism on the subdomain ...?

I am trying to redirect my domain URL to www URL with htaccess.

It works great, but the problem is that it applies even on a subdomain.

My subdomain is adminpanel.mypage.com , but the rewrite engine rewrites even the subdomain at www.adminpanel.mypage.com/adminpanel/

which is strange, and I did not expect this to work. Any possible solution?

My code is:

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

overwrites the engine already

+4
source share
1 answer

Modify the rule wwwto specify it in the main domain:

RewriteCond %{HTTP_HOST} ^mypage\.com$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NE]
+1
source

All Articles