vue-router的history模式发布配置

如果你正在尝试将基于vue-router的项目部署到windows中,希望本文能够有所帮助。

iis配置

无需安装其他组件,将错误页指向index.html即可

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <customErrors mode="On" defaultRedirect="index.html">
            <error statusCode="404" redirect="index.html" />
        </customErrors>
    </system.web>
    <system.webServer>
        <httpErrors errorMode="Custom">
            <remove statusCode="404" />    
            <remove statusCode="500" />          
            <error statusCode="500" path="/index.html" responseMode="ExecuteURL" />
            <error statusCode="404" path="/index.html" responseMode="ExecuteURL" />
        </httpErrors>
      
    </system.webServer>
</configuration>


nginx配置

启动如遇问题尝试使用命令创建/logs/nginx.pid文件:nginx -c conf/nginx.conf
不要设置环境变量,重启命令:start nginx -s -reload

server {
    listen       3355;
    location / {
        root F:/dist;
        index index.html;
        try_files $uri $uri/ /index.html;
    }      
}
posted @   易墨  阅读(2534)  评论(0编辑  收藏  举报
编辑推荐:
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
阅读排行:
· [翻译] 为什么 Tracebit 用 C# 开发
· 腾讯ima接入deepseek-r1,借用别人脑子用用成真了~
· Deepseek官网太卡,教你白嫖阿里云的Deepseek-R1满血版
· DeepSeek崛起:程序员“饭碗”被抢,还是职业进化新起点?
· RFID实践——.NET IoT程序读取高频RFID卡/标签
Fork me on GitHub
点击右上角即可分享
微信分享提示