Welcome to the E-Blah Community!
We would like to welcome you to our community and invite you to register an account or login.
Being a registered member is important, as it gives you several advantages over the normal Guest status. After registering you will be able to download files and images, post messages, and access member-only portions of the forum - just to name a few. Registration is quick and simple, and only takes about a minute of your time.

E-Blah Community    Technical Support    Question and Answer  ›  How to make all links https://
Users Browsing Forum
No Members and 4 Guests

How to make all links https://  This thread currently has 416 views. Print
1 Pages 1 Recommend Thread
johnnyhenderson
September 4, 2017, 11:21pm Report to Moderator Report to Moderator
E-Blah Member
Posts: 2
Posts Per Day: 0.00
Time Online: 3 minutes
Firstly you need an SSL Certificate from your hosting provider.

Secondly; modifying the standard Anchor .htaccess file to the following; will push all traffic through https instead of http.

Options -indexes

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 year"
</IfModule>

# 331 days
<FilesMatch ".(svg|woff|js)$">
Header set Cache-Control "max-age=28598400, public"
</FilesMatch>

<IfModule mod_rewrite.c>
    RewriteEngine On


    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*) http://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

    RewriteCond %{HTTPS} off
    RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

    RewriteBase /

    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # Rewrite all other URLs to index.php/URL
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 index.php
</IfModule>
Note: I have a few extra things in there to handle cache on a particular website.

You will get errors trying to serve http data over https, for example; if you have an image on your website, that comes from imgur, and it's http://imgur.com/imagename - it'll serve an error over https, so make sure website is delivering externally hosted assets over https too.





Revision History (1 edits)
Nat  -  September 7, 2017, 4:05am
Logged Offline
Private Message Private message
1 Pages 1 Recommend Thread
Print

E-Blah Community    Technical Support    Question and Answer  ›  How to make all links https://

Thread Tags
1,  serve,  https