因此,我有一个Vue应用程序,用于安装在apache dev服务器上的客户端.我这样做是为了适应生产环境.该应用程序位于一个子目录中,我在vue路由上设置了"base"选项以匹配.如果我导航到虚拟主机根目录,它会正确重定向,但是通过在中键入地址来导航到同一地址会得到404.
这是我的路由代码:
const routes = [
{path: '/', redirect: '/london' },
{path: '/:city', component: homeView}
]
const router = new VueRouter ({
mode: 'history',
routes,
base: '/subdir/'
})
我还有相关的Apache."子目录"中的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>
因此,如果我导航到"cityapp.local/subdir",它会重定向到"cityapp.local/subdir/london",但如果我键入"cityapp.local/subdir/london",我会看到apache 404页面.
任何 idea 或帮助都将不胜感激!
编辑:如果我将虚拟主机设置为包含subdir,并从路由中删除base选项,则一切正常.然而,我不能在生产中这样做,所以我希望这些信息能有所帮助.