-
- 463 Posts
I'd be interested to know any tips when switching a Modx site from http to https. My initial questions may sound basic and not necessarily Modx related but I've got to start somewhere!
Is there anything I need to do in the main .htaccess file or in the core/.htaccess file?
Do I need to redirect http pages to https pages?
Will there be changes in the core/config.php file?
It's a shared hosting account with php 5.6 - more information available if needed.
Thank you in advance.
-
- 932 Posts
You'll see the documentation for it in the .htaccess file.
# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
#
https://www.domain.com when your cert only allows
https://secure.domain.com
RewriteCond %{SERVER_PORT} !^443
RewriteRule (.*)
https://www.yourdomain.com/$1 [R=301,L]
-
- 463 Posts
Ah thank you!
Would I be right in saying that that would come after any other redirects? And if I had the following kind of redirects...
RewriteCond %{HTTP_HOST} ^mywebsite\.co\.uk$ [NC]
RewriteRule ^(.*)$
http://www.mywebsite.co.uk/$1 [R=301,L]
Would that need changing to...
RewriteCond %{HTTP_HOST} ^mywebsite\.co\.uk$ [NC]
RewriteRule ^(.*)$
https://www.mywebsite.co.uk/$1 [R=301,L]
...or does that final rewrite rule look after everything above it?
-
- 932 Posts
No worries. I can't tell you for sure the correct way to do it because I honestly don't know, but I do have it setup and working on one my sites with the following:
# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
# https://www.domain.com when your cert only allows https://secure.domain.com
RewriteCond %{SERVER_PORT} !^443
RewriteRule (.*) https://www.yourdomain.co.uk/$1 [R=301,L]
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]