Force site-wide HTTPS

Permalink 2 users found helpful
I've found a few addons that allow forced HTTPS per page and am looking for simplest way to force this for whole site. Grateful for any suggestions.

Thanks,
Lars.

hornborg
View Replies:
c5dragon replied on at Permalink Reply
c5dragon
Using the .htacces file in your Concrete5 directory:
Will be created when you enable clean/pretty urls.

Add the extra code:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
  RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
# -- concrete5 urls start --
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME}/index.html !-f
  RewriteCond %{REQUEST_FILENAME}/index.php !-f
  RewriteRule . index.php [L]
# -- concrete5 urls end --
</IfModule>
hornborg replied on at Permalink Reply
hornborg
Thanks a million! I do have pretty URL's activated and kind find the .htaccess file. Where would it normally be located?
c5dragon replied on at Permalink Reply 1 Attachment
c5dragon
In the root directory of your concrete5 site (see attached).
You need to enable the option to see invisible files (in your file manger | finder | explorer).
hornborg replied on at Permalink Reply
hornborg
Excellent, double thanks!
CMSDeveloper replied on at Permalink Reply
CMSDeveloper
@c5dragon

Hi, your .htaccess code for forcing SSL redirects will work
if a domain has the "www." in the url.
See also some code that is not supported anymore by mod_rewrite (php v7.xx)

Better is to hardcode the domain name in the .htacces file.

See:
https://www.concrete5.org/community/forums/customizing_c5/how-to-for...
Example .htaccess(.zip)
https://www.concrete5.org/download_file/-/99089/htaccess.zip...
c5dragon replied on at Permalink Reply
c5dragon
Mine works on both www and non www, but makes the end url https non www (as intended).
Didn't test on php7.

Some handy site to test you htaccess:
http://htaccess.mwl.be/
hornborg replied on at Permalink Reply
hornborg
I love the replies to my question. Many thanks for this tip!