vue-router
全局配置
const router = new VueRouter({
mode: 'history',
routes: [...]
})
URL Rewrite
1、添加規則
2、設置規則
使用正則表達式匹配網址,模式:就是正則表達式;
條件可以設置服務器變量對應匹配,如上面只匹配www.local.com
服務器變量
https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524602(v=vs.90)
這里的{R:0}就是上面正則表達式匹配的內容:可以通過測試模式查看;也可以通過正則表達式的分組匹配去做跳轉規則
3、web.config
打開可以看到剛才的配置自動寫入web.config的內容
<system.webServer> <rewrite> <rules> <rule name="測試規則" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^www.local.com$" /> </conditions> <action type="Redirect" url="http://www.asd.com/{R:0}" redirectType="Found" /> </rule> </rules> </rewrite> </system.webServer>

<system.webServer> <rewrite> <rules> <rule name="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="/" /> </rule> </rules> </rewrite> </system.webServer>
資源:
安裝url-rewrite:
https://www.iis.net/downloads/microsoft/url-rewrite
正則表達式工具:
http://deerchao.net/tools/regester/index.htm
博客
https://shiyousan.com/post/635654920639643421
vue地址重寫