XenForo Tutorials

[TUTORIAL] How to force HTTPS on your forum using .htaccess

Submitted by tivum, , Thread ID: 51861

Thread Closed
tivum
l33cher
Level:
0
Reputation:
-5
Posts:
242
Likes:
40
Credits:
52
18-10-2017, 02:22 PM
This post was last modified: 18-10-2017, 02:30 PM by tivum
#1
As we all know, Google admitted that having an SSL certificate will make your website ranking a little bit better, it also secures the website. Today i'm going to show you how to force https on your website.

First you need to open up your document root whether that's a folder called www/ or maybe public_html/
You need to find your .htaccess file. NOTE: If you're on cPanel file manager, you're dotfiles will be hidden, dotfiles are files like .htaccess and files that begin with a dot, you'll need to go up in the right hand corner and click the settings button and click show dotfiles (hidden).

You then want to go to your document root and file your .htaccess file and open it to edit it.

Important:If you have existing code in your .htacess, add this above where there are already rules with a similar starting prefix.


Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]


Be sure to replacewww.example.comwith your actual domain name.
To force aspecific domainto use HTTPS, use the following lines of code in the .htaccess file in your website's root folder:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]


Make sure to replaceexample\.comwith the domain name you're trying force to https. Additionally, you need to replacewww.example.comwith your actual domain name.
If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that specific folder:

Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L][/size][/color]

Make sure you change thefolderreference to the actual folder name. Then be sure to replacewww.example.com/folderwith your actual domain name and folder you want to force the SSL on.

I hope i've helped someone, if you have any questions feel free to ask and i'll try to help to the best of my ability.

RE: [TUTORIAL] How to force HTTPS on your forum using .htaccess

dzhen94
Active Member
Level:
1
Reputation:
14
Posts:
286
Likes:
56
Credits:
762
18-10-2017, 02:29 PM
#2
18-10-2017, 02:22 PM
tivum Wrote:
Code:
[color=#000000][size=x-small]RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L][/size][/color]

I think thats no need to add
Code:
[color=#000000][size=x-small]

Didnt ya? CMIIW
[ Awesome PPL Aoki v4hl MarcFrid Yondu url Sui ]

[Image: Signs.png]

RE: [TUTORIAL] How to force HTTPS on your forum using .htaccess

tivum
l33cher
Level:
0
Reputation:
-5
Posts:
242
Likes:
40
Credits:
52
OP
18-10-2017, 02:30 PM
#3
18-10-2017, 02:29 PM
dzhen94 Wrote:
I think thats no need to add
Code:
[color=#000000][size=x-small]

Didnt ya? CMIIW
I fixed it, I have no idea how that got there lmao.

RE: [TUTORIAL] How to force HTTPS on your forum using .htaccess

dzhen94
Active Member
Level:
1
Reputation:
14
Posts:
286
Likes:
56
Credits:
762
18-10-2017, 02:33 PM
#4
And I also think, it seems this way also applies to all websites, not just for xenforo users only. Right?
[ Awesome PPL Aoki v4hl MarcFrid Yondu url Sui ]

[Image: Signs.png]

RE: [TUTORIAL] How to force HTTPS on your forum using .htaccess

tivum
l33cher
Level:
0
Reputation:
-5
Posts:
242
Likes:
40
Credits:
52
OP
18-10-2017, 02:40 PM
#5
18-10-2017, 02:33 PM
dzhen94 Wrote:
And I also think, it seems this way also applies to all websites, not just for xenforo users only. Right?

Yeah but I figured i'd post it on here because just changing the url in the ACP won't force https.

RE: [TUTORIAL] How to force HTTPS on your forum using .htaccess

Drakeoo
Closed Account
Level:
0
Reputation:
0
Posts:
2
Likes:
0
Credits:
2
28-10-2017, 04:18 PM
#6
Very good tutorial write more! You describe well and others!

RE: [TUTORIAL] How to force HTTPS on your forum using .htaccess

Pleaded
Closed Account
Level:
0
Reputation:
0
Posts:
2
Likes:
0
Credits:
2
31-10-2017, 07:07 PM
#7
Mk just posting so I can get a dl lmao GG No ReMk just posting so I can get a dl lmao GG No Re

RE: [TUTORIAL] How to force HTTPS on your forum using .htaccess

Flexxnes
Closed Account
Level:
0
Reputation:
0
Posts:
11
Likes:
0
Credits:
15
29-11-2017, 03:09 AM
#8
Thank you for sharing! <3 This add-on helped me so much on my site.

Users browsing this thread: 1 Guest(s)