如何在 php、apache 服务器编写的网站子路径上激活 vue-router 的历史模式?
How to activate the history mode of the vue-router on a subrout of a website written in php, apache server?
我在我的网站上的 apache 服务器上包含一个 SPA,但是当访问这个路由时,我加载了视图,但路由 returns 到主域。我应该如何配置路由器或 .htaccess
来纠正这个问题?
我的网站就像 www.example.com
,Vue SPA 位于 www.example.com/en/route1/route2/spa
.
当我访问此路由时,Vue SPA 加载但路由 returns 到主域 www.example.com
,并且 Vue SPA 路由照常加载但在主域路由中,如 www.example.com/spa/spaRoute1
.
我想要的是保留 Vue SPA 的原始路由,以显示从那里开始的 SPA 路由,例如 www.example.com/en/route1/route2/spa/spaRoute1
使用 Vue-Router 的历史模式。
我试过像 vue-router 的文档那样修改 .htacces
但它没有帮助。
https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations
我的路由器是这样的历史模式:
export default new Router({
mode: 'history',
etc....
})
我的 .htaccess 使用 vue-router 文档的配置
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
您试过使用基础 属性 吗? https://router.vuejs.org/api/#base