I have a bit of an odd problem. My rewrite rules appear to work just as I would expect, but not for sub-pages.
www to none www always works, but forcing https does not work on some pages.
All rules do work however on the home page, so that's all good.
<IfModule mod_rewrite.c>
# Wordpress related rewrite.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# www and https rules.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
Results:
- http://example.com -> https://example.com (good)
- http://www.example.com -> https://example.com (good)
- https://example.com -> https://example.com (good)
- https://www.example.com -> https://example.com (good)
However, sub-pages do not appear to be working correctly:
- https://example.com/page -> https://example.com/page (good)
- https://www.example.com/page -> https://example.com/page (good)
- http://example.com/page -> http://example.com/page (bad)
- http://www.example.com/page -> http://example.com/page (bad)
Any idea how I can improve this rewrite to work with no www and https regardless of my location?
Thanks