【发布时间】:2021-11-24 08:02:30
【问题描述】:
我有一个 vue.js 应用程序,它包含 2 个入口点 (2 SPA's)。其中一个是index.html,为客户网站服务,另一个为平台(platform.html)
按照 Vue CLI 文档,我在 .htacess 文件中使用以下内容
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
这仅在我只有 index.html 并且当我输入 myUrl.com/platform 时才有效,它不会更改为平台。
我尝试了以下方法,但无法正常工作
<IfModule mod_rewrite.c>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^platform(.*)$ platform.html [L]
RewriteRule ^(.*)$ index.html [L]
</IfModule>
</IfModule>
【问题讨论】:
-
两个平台的网址是什么?是
/platform/<something>还是/platform<something>(您的问题可能暗示)? -
@MrWhite 是这样的
/platform/<subroute> -
在这种情况下,
RewriteRulepattern 会比^platform($|/)更好,而不是简单的^platform,以避免潜在的匹配过多。我已经更新了我的答案。
标签: apache vue.js .htaccess mod-rewrite url-rewriting