1

A bit out of my comfort zone, hoping someone can point me in the right direction! I need to force all http://www.mywebsite.com to go to https://sub.mywebsite.com.

So, I need to force all visitors to the sub-domain, but also the secure https version.

I've tried editing the root htaccess file but I get 'too many redirects' error. The new site is using a Wordpress child theme in case that makes a difference - when I edited the root htaccess the site appeared unstyled and the 'too many redirects' error related to CSS and JS files.

I'm sure it's something silly and small but any help, much appreciated! :-) Thanks

1 Answer 1

2

Try putting this into the htaccess file above all other existing rules:

RewriteEngine On

# First redirect to the subdomain
RewriteCond %{HTTP_HOST} ^(www\.)?example.com
RewriteRule ^(.*)$ https://sub.example.com%{REQUEST_URI} [L,R=301]

# Then ensure HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://sub.example.com/$1 [L,R=301]
2
  • Thank you so much!! Totally fixed the problem - you are awesome thank you!
    – AdeleMB
    Commented Sep 18, 2016 at 18:03
  • Glad that I could help :)
    – Elin Y.
    Commented Sep 18, 2016 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.