<VirtualHost *:80> ServerAdmin webmasterexample.com DocumentRoot "/mnt/www/" ServerName www.test.com ServerAlias #HTTP_TO_HTTPS_START #301-START <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.test.com/$1 [R=301,L] </IfModule> </VirtualHost>
在你的网站配置文件*.conf 中修改