我在 apache 服务器的网站包含一个 SPA,但是当访问此路由时,我加载视图但路由返回到主域。我应该如何配置路由器或.htaccess
来纠正此问题?
我的网站就像www.example.com
,Vue SPA位于www.example.com/en/route1/route2/spa
。
当我访问此路由时,Vue SPA 加载但路由返回到主域www.example.com
,并且 Vue SPA 路由像往常一样加载,但在主域路由中,如www.example.com/spa/spaRoute1
。
我想要的是保留 Vue SPA 的原始路由,从那里显示 SPA 路由,就像使用 Vue-Router 的历史模式www.example.com/en/route1/route2/spa/spaRoute1
一样。
我尝试修改.htacces
,例如 vue-router show 的文档,但它没有帮助。
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