Apache .htaccess强制https并重定向到文件夹

时间:2018-05-28 18:17:58

标签: apache .htaccess

我正在尝试在生产apache服务器中强制执行https,同时仅将根路由'/'重定向到子文件夹'/ front',因此重定向到子文件夹工作正常,但不是https强制。

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^$ /front [L]

RewriteCond %{HTTP_HOST} !=localhost [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R]

1 个答案:

答案 0 :(得分:0)

我终于找到了解决方案:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

DirectoryIndex /front/index.html

RewriteCond %{HTTP_HOST} !=localhost [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [R]