建设网站需要的资质证书,网站制作自己接单,南昌网站公司,艺术网站模板history模式配置后刷新404的解决办法! 第一种 nginx配置 在usr/local/nginx/conf/vhost 下 域名.conf配置文件修改或添加 第一种方案server {##在server下添加或在location里面添加以下代码location / {if (!-e $request_filename) {rewrite ^(.*)$ /index.html?s$1 last…history模式配置后刷新404的解决办法! 第一种 nginx配置 在usr/local/nginx/conf/vhost 下 域名.conf配置文件修改或添加 第一种方案server {##在server下添加或在location里面添加以下代码location / {if (!-e $request_filename) {rewrite ^(.*)$ /index.html?s$1 last;break;}}## 如果访问的不是根目录用下面方式设置 qiancheng是我的子目录location /qiancheng{if (!-e $request_filename) {rewrite ^/(.*) /qiancheng/index.html last;break;}}} 第二种方案location / {try_files $uri $uri/ /index.html; } 第二种 Apache IfModule mod_rewrite.cRewriteEngine OnRewriteBase /RewriteRule ^index\.html$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.html [L]
/IfModule 第三种 原生 Node.js const http require(http)
const fs require(fs)
const httpPort 80http.createServer((req, res) {fs.readFile(index.htm, utf-8, (err, content) {if (err) {console.log(We cannot open index.htm file.)}res.writeHead(200, {Content-Type: text/html; charsetutf-8})res.end(content)})
}).listen(httpPort, () {console.log(Server listening on: http://localhost:%s, httpPort)
}) 第四种 Firebase 主机 在你的 firebase.json 中加入
{hosting: {public: dist,rewrites: [{source: **,destination: /index.html}]}
} 第五种 tomcat的配置 添加 WEB-INF文件夹web.xml文件 加入下列代码web-app error-page error-code404/error-code location/index.html/location /error-page /web-app 参考文件 https://router.vuejs.org/zh/guide/essentials/history-mode.html#%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90转载于:https://www.cnblogs.com/miaoyiyan/p/9635566.html