Subdomain redirect from www to non-www

I have my .htaccess files set up in the main domain and subdomain to redirect to non-www. The main domain works fine but the subdomain is not working.

I have the following in my .htaccess

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.my.emotional-salary.com [NC]
RewriteRule (.*) | Error 404 [L,R=301]

Had a look at rules but wasn’t sure how to write a rule for a sub-domain or if an overall rule can be written which will automatically alter subdomains.

Any help greatly appreciated

As long as that www request comes in on HTTP, it will work.

On the other hand, on HTTPS it won’t work because of the certificate issue covered by this article.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.