Use .htaccess to redirect HTTP to HTTPs

后端 未结 17 1609
刺人心
刺人心 2020-12-02 05:51

Please, don\'t recommend me the long and very detailed thread with more than 173 upvotes. It didn\'t work for me. I have also tried many others (1, 2, 3, 4). They all give m

17条回答
  •  心在旅途
    2020-12-02 06:21

    This is tested and safe to use

    Why?: When Wordpress editing your re-write rules, so make sure your HTTPS rule should not be removed! so this is no conflict with native Wordpress rules.

    
       RewriteCond %{HTTPS} !=on
       RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
    
    
    # BEGIN WordPress
    
      #Your our Wordpress rewrite rules...
    
    # END WordPress
    

    Note: You have to change WordPress Address & Site Address urls to https:// in General Settings also (wp-admin/options-general.php)

提交回复
热议问题