我在这里创建了一个包含多个页面的小型测试:http://media.eurolines-group.ro/website/当我在 localhost 上工作并访问其中一个页面时,它工作得很好 - 但是当我尝试在服务器 (apache( 上访问它时,我收到 404 错误 - 例如:http://media.eurolines-group.ro/website/about。 有没有办法当我直接输入/关于 ,/联系/工作 - 返回页面?
这是我的脚本:
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>
路由器/索引.js
export default new Router({
mode: 'history',
base: '/website/',
routes: [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
component: About
},
{
path: '/contact',
name: 'Contact',
component: Contact
},
{
path: '/jobs',
name: 'Jobs',
component: Jobs
}
]
})
配置.js
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: 'http://media.eurolines-group.ro/website',
提前感谢!
我在有人的帮助下想通了 - 如果其他人遇到此问题: 我用这个替换了我htaccess中的所有内容:
FallbackResource index.html