Forcing SSL with .htaccess, cPanel & CloudFlare

HostBastic

Well-known member
Joined
Nov 17, 2016
Messages
317
Best answers
1
Ratings
39 2
Points
28
#1
Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you have an existing .htaccess file:

- Do not duplicate RewriteEngine On.
- Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On.


Forcing SSL via cPanel follow this steps:

- access the redirects section
- set permanent (301) redirect
- choose the domain name
- enter the site's url using the SSL certificate
- make sure wild card redirect is selected
- select redirect with or without www


Forcing SSL via CloudFlare follow this steps:

- Login into your CloudFlare account, choose the domain which you wish to enforce the SSL.
- From there select the Page Rules section and select Create Page Rules.
- Add your URL and select Add a Setting.
- Under Add a Setting select SSL and for SSL Settings choose Full.
 

Maxoq

Well-known member
Joined
Feb 25, 2015
Messages
340
Best answers
0
Ratings
40 1
Points
28
#2
This is a good option to force SSL (https) with .htaccess file
By the way, you know ways to enable SSL for websites that using Cloudflare or enable SSL from cPanel ?
 

energizedit

Well-known member
Joined
Dec 13, 2016
Messages
259
Best answers
0
Ratings
14
Points
18
#3

HostBastic

Well-known member
Joined
Nov 17, 2016
Messages
317
Best answers
1
Ratings
39 2
Points
28
#4
If you wish to force SSL via cPanel follow this steps:

- access the redirects section
- set permanent (301) redirect
- choose the domain name
- enter the site's url using the SSL certificate
- make sure wild card redirect is selected
- select redirect with or without www

With CloudFlare you can do so by creating a page rule which enforces HTTPS for the selected URL.
 

Maxoq

Well-known member
Joined
Feb 25, 2015
Messages
340
Best answers
0
Ratings
40 1
Points
28
#5
If you wish to force SSL via cPanel follow this steps:

- access the redirects section
- set permanent (301) redirect
- choose the domain name
- enter the site's url using the SSL certificate
- make sure wild card redirect is selected
- select redirect with or without www
Thanks for the tips!
I could do this on my cPanel.

With CloudFlare you can do so by creating a page rule which enforces HTTPS for the selected URL.
Can you go into the details for this step with some screenshots or where I can create and how to setup them?
 

HostBastic

Well-known member
Joined
Nov 17, 2016
Messages
317
Best answers
1
Ratings
39 2
Points
28
#6
HostBastic
1. Login into your CloudFlare account, choose the domain which you wish to enforce the SSL.
2. From there select the Page Rules section and select Create Page Rules.
3. Add your URL and select Add a Setting.
4. Under Add a Setting select SSL and for SSL Settings choose Full.
 

hostens

Well-known member
Joined
Jan 18, 2017
Messages
189
Best answers
2
Ratings
72 8
Points
28
#8
If you want to enforce SSL only on specific page of your website you can change .htaccess rule as follows:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule register.php https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]​

Where "register.php" would be part of website that needs to be encrypted.
 

24x7serverman

Well-known member
Joined
Jul 25, 2017
Messages
651
Best answers
1
Ratings
68 6
Points
28
#9
Thanks for sharing the article. :)

I would like to provide one more tip - SSL used to work from the server where your website is pointing so you should always install the SSL from the server where your site is hosted and working.


For green padlock in browser, you will need to replace every instance of http to https and will need to update your site and home URL in database.
 
Latest Threads
Recommended Threads
Replies
8
Views
2,849
Replies
1
Views
1,391
Replies
0
Views
1,347

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Latest Blog ArticlesMost Viewed Threads

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top