.HTTPS重定向和客户端路由的HTACCESS配置



我有apache 2.4.27和两个问题:

1。重定向http-> https

2。

1 的解决方案(它起作用(:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

2 的解决方案(VUE官方推荐(:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

如何满足这两个条件?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^yoursite.domen [NC]
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST} [R=301,L]
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

简单:解决方案1 解决方案2 =它工作

最新更新