My primary domain is currently permanently redirected to www.mydomain.com (non-www to www redirection), with .htaccess as follows:
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^/?$ "http\:\/\/www\.mydomain\.com\/" [R=301,L]
RewriteCond %{HTTP_REFERER} !^http://mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com$ [NC]
I would like to know how all subdomains that I'll be creating, ex. blog.mydomain.com, will be redirected to non-www, ex. blog.mydomain.com, and not www.blog.mydomain.com. Every time I create a subdomain and enter the non-www URL to the browser, it prompts a redirect loop.
Hope you can help! Thanks! :)
Keep this one rule for all the sub-domains:
This one supports
http
+https
in one line: