vue-router history模式,服务器配置后,访问报500错误
我的web
服务器有二级目录promotion
,于是配置了router
和config
//项目源码目录/src/router/index.js
import Vue from "vue";
import Router from "vue-router";
import notFound from "@/components/notFound";
import index from "@/views/index";
Vue.use(Router);
export default new Router({
mode: "history",
base:"/promotion/",
routes: [
{ path: "*", component: notFound },
{
path: "/index",
name: "index",
component: index
}
]
});
//项目源码目录/config/index.js
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/promotion/',
}
服务器用的IIS
管理,网站根目录配置了web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/promotion/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
最终访问地址,域名/promotion/index
,页面报了500
错误,这是什么原因?怎么解决?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
router
中配置的base:"/promotion/"
去掉