Use .htaccess to redirect HTTP to HTTPs

后端 未结 17 1601
刺人心
刺人心 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:19

    None if this worked for me. First of all I had to look at my provider to see how they activate SSL in .htaccess my provider gives

    
       RewriteEngine On
       RewriteCond %{HTTP:HTTPS} !on
       RewriteRule (.*) https://%{SERVER_NAME}/$1 [QSA,L,R=301]
    
    

    But what took me days of research is I had to add to wp-config.php the following lines as my provided site is behind a proxy :

    /**
     * Force le SSL
     */
    define('FORCE_SSL_ADMIN', true);
    if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) $_SERVER['HTTPS']='on';
    

提交回复
热议问题