vue spa項目,history模式,https://news.otimes.com/list/... 這種帶參數(shù)的鏈接,安卓微信瀏覽器顯示404,https://news.otimes.com 不帶參數(shù)的鏈接能顯示,跳轉(zhuǎn)也是正常的,是不是安卓瀏覽器不能兼容history模式,我可以怎么改嗎?
前端配置了
{
path: '*',
name: 'notFind',
meta: {
title: '404未找到',
},
components: setLogoComponents(notFind)
},
后臺是tomcat,也配置了
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
火狐,谷歌,ie下都沒有404,微信開發(fā)工具雖然也有404,但還是能訪問,只有安卓微信瀏覽器,404
ps:https證書已布上,也是已備案的域名,微信js安全域名和白名單都已配置
1.chrome模擬器,能訪問,無404,
2.微信開發(fā)者工具,能訪問,有404
3.安卓手機微信瀏覽器,不能訪問,有404
感謝這位大神,寫的都很清楚了,http://blog.csdn.net/xu122723...。
問題的主要原因是,雖然tomcat已經(jīng)攔截了404,并指向了我的index頁面,但是這個404的標記還是存在,只要遇見存在404錯誤頁處理的平臺,就gg了。就比如微信平臺,他檢測到你的404,就立馬跳向公益404頁面了。
解決方法一:后臺設(shè)置攔截器,在發(fā)送任何請求前,后臺都做攔截,并指向index頁面。
解決方法二:用nginx進行攔截,修改nginx.conf文件
http {
# 此處省略好多字
server {
# nginx才配使用80端口,其他服務(wù)速速離去
listen 80;
# 沒啥好解釋的
server_name localhost;
# 指定根目錄,由于我的前端項目是直接放在nginx下的html文件夾,所以我這樣配
root html;
# 這里其實是由if變過來的,意思是如果uri存在,那就訪問uri的資源,如果uri不存在,那就訪問該目錄下index.html文件。如果看不懂我的解釋,可以看這個https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#front-controller-pattern-web-apps
try_files $uri $uri/ /index.html;
# 這里是配你Tomcat里面的其他java項目,意思是當你訪問http://ip/xxx的時候,會到這個代碼塊里面進行對應(yīng)操作
location /xxx {
# 這些照著加就好了,無非是獲取服務(wù)器host/ip相關(guān),一定要加,否則如果你的項目并不是前后端分離,而是SSH/SSM帶有jsp或者模板頁面的,那就會出現(xiàn)找不到css/js等找不到一切靜態(tài)資源文件的錯誤。為什么會報錯,因為你看network面板你就知道,他是去訪問http://127.0.0.1/xxx/css...而并不是訪問服務(wù)器的真實ip,所以還是乖乖加上吧!
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 去該地址去找項目資源
proxy_pass http://127.0.0.1:8080/xxx;
}
}
}
upstream ups_ucar_wx {
#ip_hash;
#consistent_hash $remote_addr;
server 192.168.8.59:8080;
#check interval=10000 rise=2 fall=5 timeout=1000 type=http default_down=false;
#check_http_send "GET /health HTTP/1.0\r\n\r\n";
}
server {
listen 80;
server_name xxx.com;
charset utf-8;
access_log logs/xxx.access.log main;
error_log logs/xxx.error.log;
#include /etc/nginx/agent_deny.conf;
location / {
proxy_pass http://ups_ucar_wx;
# 具體做什么,不懂,不過不加會顯示400
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 匹配不到的路徑,都跳/index.html
try_files $uri $uri/ /index.html;
}
location /static/ {
root /;
proxy_pass http://ups_ucar_wx;
# 具體做什么,不懂,不過不加會顯示400
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 設(shè)置過期時間
expires 30d;
}
}
北大青鳥APTECH成立于1999年。依托北京大學優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學院和江蘇省首批服務(wù)外包人才培訓基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團,成為集合面授教學培訓、網(wǎng)
達內(nèi)教育集團成立于2002年,是一家由留學海歸創(chuàng)辦的高端職業(yè)教育培訓機構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責任公司從事總經(jīng)理職務(wù)負責iOS教學及管理工作。
浪潮集團項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風格 授課風格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。