【发布时间】:2021-11-18 15:20:26
【问题描述】:
我有一个 vue-laravel 水疗中心。为了让 vue 应用程序在历史模式下正常工作,我需要确保它重定向到 index.html。我正在遵循 vue cli 文档中的说明,并在 .htaccess 文件中使用这段代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
同时,我还需要确保所有 http 请求都被重定向到 https,我的 hostgator 托管为我提供了这段代码。
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$
RewriteRule ^/?$ "https\:\/\/subdomain\.domain\.com\/" [R=301,L]
问题是这两段代码似乎不能一起工作。但是,当另一个被注释掉时,它们中的每一个都可以工作。
【问题讨论】:
标签: vue.js .htaccess single-page-application vue-cli