WordPress Force HTTPS Redirection Without Plugin

withoutplugin
https
ssl

(Santhosh veer) #1

Hey, Guys Most of them Using Plugin for Force HTTPS Redirection in Wordpress.Instead of Force SSL Redirect Plugin Use HTACCESS Rule for Force HTTPS Redirection.

  • Every time trusting Plugin is Not a Good Idea

  • Easy to add you can Find the HTACCESS File on your Hosting File Manager or Add via through Yoast SEO Plugin Yoast SEO > Tools > File Editor

Here’s the HTACCESS code for Force SSL Redirect (For HTTPS Redirection)

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Important things to do after installing SSL (HTTPS) on your website
Does anybody know about this Error?
Best free 'trusted' SSL (https) certificate providers list for you!
HTACCESS useful Rewrite Codes 2017
Few doubts after Migrating my site from Http to https?
Useful Code Snippets and Functions For your WordPress Site :tada:
Switching from "HTTPS" (SSL) to "HTTP" (Important Things!)
(Pradeep Kumar) #2

Awesome bro! We can also add this in the wp-config.php file right?

define(‘FORCE_SSL_ADMIN’, true);


(Santhosh veer) #3

No bro HTACCESS Rule is Enough bro :blush:


(Akash Patil) #4

I was using Really Simple SSL Plugin, But this method seems nice and simple :slight_smile: Thanks for sharing it @mskian


(Santhosh veer) #5

Thanks, bro No More Extra Setups Now :relaxed: :blush:


(Jithesh Kt) #6

I assume declaring this constant is required in some plugins to understand that your installation have SSL. So it is always better to define ‘FORCE_SSL_ADMIN’.


(Santhosh veer) #7

we are using that HTACCESS rule on our all blogs/websites Working fine Without any ISSUE

this below rule covers all folders and files

RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

No need to use

define(‘FORCE_SSL_ADMIN’, true);

(Pradeep Kumar) #8

Cool guys! But nothing’s wrong in trying both I guess, if your theme or blog still has some issues, we can enable the force SSL option in wp-config.php and see if it helps. :slight_smile:


(Jithesh Kt) #9

I didn’t said it won’t work :smile: But declaring that variable might be needed some times. Simple logic, that constant developed for a purpose right ?


(Santhosh veer) #10

sometime HTTPS error due to sidebar banners/Widgets/Images/Affiliate LInks which having HTTP URL version.
Reupload the Favicon and Logo
Check you all sidebar Widgets If you Find HTTP version Replace it with HTTPS version bro.


(Prabhat Jani) #11

Yesterday i added ssl. i used these .htaccess but its was not working for inner pages. They were not redirecting to https.

Then i used simple ssl plugin. and now working fine.


(Santhosh veer) #12

:fearful: then How it works for me? :rolling_eyes: After adding this Rule Clear Cache & Check the pages Sir

we are Using this rule only No issues from my Side


(Prabhat Jani) #13

Aray bro. I am not saying ki you are wrong.

I just shared what i have done.

:innocent:


(Nik Phirke) #14

@pradeepkumar define (‘FORCE_SSL_ADMIN’, true); only enables SSL on WordPress login page i.e. wp-login.php and dashboard and not on full site.

Adding the code by mskian should work properly if one want to have ssl over full site including any direct urls to files and folders.

@prabhat This should have worked with you, maybe you had extra space which you didn’t notice…and if plugin is doing the job for you, then keep it :slight_smile:


(Prabhat Jani) #15

maybe you had extra space ?

What you want to say sir ?:joy:

Actually i dont know much about coding. Last time something went wrong. kya batau.


(Pradeep Kumar) #17

“extra space” in the .htaccess code bro. :slight_smile:


(Arnab Mohapatra) #18

For a newbie editing, HTACCESS is risky & if something wents wrong takes hours to recover it!
So I will suggest to use Really Simple SSL!
It is free does all the necessary steps


(Sufyan Shaikh) #19

Hello All,

I would suggest changing your site settings and wordpress settings from http:// to https://

Make sure your host supports free SSL like Letsencrypt.

Once all is done install Really Simple SSL plugin.

It will handle your 301 redirection without messing up with the code :slight_smile:


(Arun Sathiya) #20

I use this too and is very handy.


(Arun Sathiya) #21

CloudFlare + LetsEncrypt + Really Simple SSL plugin + CloudFlare flexible SSL = <3