vue下history模式刷新后404錯(cuò)誤解決方法
本文介紹了vue下history模式刷新后404錯(cuò)誤解決方法,分享給大家,具體如下:
官方說(shuō)明文檔:
https://router.vuejs.org/zh/guide/essentials/history-mode.html
一、 實(shí)測(cè) Linux 系統(tǒng) Apache 配置:
更改站點(diǎn)配置文件即可,我這里在 Directory 標(biāo)簽后面添加了官方給的五行配置
<VirtualHost *:80>
#Created by linvic on 2018-05-24
Serveradmin 674206994@qq.com
ServerName blog.xxx.com
DocumentRoot /home/www/blog
<Directory "/home/www/blog">
Options FollowSymLinks
AllowOverride All
#Require all denied
Require all granted
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</Directory>
</VirtualHost>
二、 實(shí)測(cè) Windows 環(huán)境下 IIS 配置
1. IIS安裝Url重寫(xiě)功能
https://msdn.microsoft.com/zh-cn/gg192883.aspx
- 到該網(wǎng)站下載安裝web平臺(tái)安裝程序
- 安裝后打開(kāi)到里面搜索安裝URL重寫(xiě)功能
2. web.config
將web.config 文件放置于 npm run build 打包后文件的根目錄即可。
ps:此文件會(huì)自動(dòng)給IIS上的URL重寫(xiě)功能進(jìn)行相關(guān)配置
文件內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="font/x-woff2" />
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="font/x-ttf" />
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="text/json" />
</staticContent>
<rewrite>
<rules>
<rule name="vue" 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="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
configureWebpack、chainWebpack配置vue.config.js方式
這篇文章主要介紹了configureWebpack、chainWebpack配置vue.config.js方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-01-01
el-select 點(diǎn)擊按鈕滾動(dòng)到選擇框頂部的實(shí)現(xiàn)代碼
本文通過(guò)實(shí)例代碼給大家分享el-select 點(diǎn)擊按鈕滾動(dòng)到選擇框頂部效果,主要代碼是在visibleChange在這個(gè)popper里面找到.el-select-dropdown__list,感興趣的朋友跟隨小編一起看看吧2024-05-05
Vue3哈希模式實(shí)現(xiàn)錨點(diǎn)導(dǎo)航方式
這篇文章主要介紹了Vue3哈希模式實(shí)現(xiàn)錨點(diǎn)導(dǎo)航方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-04-04
用vue實(shí)現(xiàn)注冊(cè)頁(yè)效果?vue實(shí)現(xiàn)短信驗(yàn)證碼登錄
這篇文章主要為大家詳細(xì)介紹了用vue實(shí)現(xiàn)注冊(cè)頁(yè),短信驗(yàn)證碼登錄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11
Vue實(shí)現(xiàn)移動(dòng)端日歷的示例代碼
工作中遇到一個(gè)需求是根據(jù)日歷查看某一天/某一周/某一月的睡眠報(bào)告,但是找了好多日歷組件都不是很符合需求,只好自己手寫(xiě)一個(gè)日歷組件,順便記錄一下,希望對(duì)大家有所幫助2023-04-04
vue實(shí)現(xiàn)自定義"模態(tài)彈窗"組件實(shí)例代碼
頁(yè)面中會(huì)有很多時(shí)候需要彈窗提示,我們可以寫(xiě)一個(gè)彈窗組件,下面這篇文章主要給大家介紹了關(guān)于vue實(shí)現(xiàn)自定義"模態(tài)彈窗"組件的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2021-12-12
vue+ElementUI 關(guān)閉對(duì)話(huà)框清空驗(yàn)證,清除form表單的操作
這篇文章主要介紹了vue+ElementUI 關(guān)閉對(duì)話(huà)框清空驗(yàn)證,清除form表單的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-08-08

