htaccess redirect to https://www

前端 未结 14 2035
夕颜
夕颜 2020-11-21 11:01

I have the following htaccess code:



RewriteEngine On
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{RE         


        
14条回答
  •  忘了有多久
    2020-11-21 11:40

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

    Notes: Make sure you have done the following steps

    1. sudo a2enmod rewrite
    2. sudo service apache2 restart
    3. Add Following in your vhost file, located at /etc/apache2/sites-available/000-default.conf
    
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
      Require all granted
    
    

    Now your .htaccess will work and your site will redirect to http:// to https://www

提交回复
热议问题