当前位置: 首页 > news >正文

网站分布百度高级搜索

网站分布,百度高级搜索,邢台市教育考试院,wordpress 侧 悬浮插件问题描述 在使用Vue.js构建的单页应用(SPA)中,特别是像ruoyi-vue这样的框架,如果启用了HTML5历史记录模式进行路由管理,那么用户直接访问子路径或刷新页面时可能会遇到404错误。这是因为当用户尝试访问一个非根路径时…

问题描述

在使用Vue.js构建的单页应用(SPA)中,特别是像ruoyi-vue这样的框架,如果启用了HTML5历史记录模式进行路由管理,那么用户直接访问子路径或刷新页面时可能会遇到404错误。这是因为当用户尝试访问一个非根路径时,Nginx会尝试查找对应的具体文件或目录,而这些资源实际上并不存在于服务器上,导致返回404错误。



原因分析

该问题的根本原因在于Nginx默认的行为是直接根据请求的URL去寻找静态资源或后端API接口。然而,在单页应用中,所有的前端路由都是通过JavaScript动态处理的,并没有实际对应的物理文件。因此,当用户直接访问或刷新某个子路径时,Nginx无法找到相应的文件,从而返回404错误。

解决方案

为了使Nginx能够正确处理单页应用的前端路由,我们需要配置Nginx,使其对于所有找不到具体文件或目录的请求都返回index.html文件。这允许Vue Router接管并根据前端路由配置来显示正确的页面内容。

可以在Nginx配置中的server块内添加以下location指令:

location / {try_files $uri $uri/ /index.html;
}

这段配置的作用是:

  • $uri:首先尝试匹配具体的文件。
  • $uri/:如果未找到文件,则尝试匹配作为目录。
  • /index.html:如果前两步均未成功,则提供index.html文件给客户端,让Vue Router处理剩下的路由逻辑。

完整的Nginx配置示例

conf {# 用于 test.com 的 HTTP 服务器块server {listen 80;server_name test.com;# 将所有 HTTP 请求重定向到 HTTPSreturn 301 https://$host$request_uri;}# 用于 test.com 的 HTTPS 服务器块server {listen 443 ssl;server_name test.com;ssl_certificate   /etc/nginx/cert/test.com.pem;ssl_certificate_key  /etc/nginx/cert/test.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;# 处理前端页面location / {root   /system/a/b/c/index;  # 前端构建输出目录index  index.html index.htm;try_files $uri $uri/ /index.html;  # 尝试访问静态文件,如果不存在则返回 index.html}# 处理 API 请求location /test/ {proxy_set_header host                $host;proxy_set_header X-forwarded-for     $proxy_add_x_forwarded_for;proxy_set_header X-Real-IP           $remote_addr;proxy_pass http://127.0.0.1:9090/;  # 将请求代理到本地 9090 端口# WebSocket 支持proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}}}

针对服务器面板

如果使用了服务器面板,可以支持一键可视化配置网站应用,但是默认的配置对于SPA单页应用并不友好,需要手动修改配置,常见的面板有(宝塔1Panel),由于我是用的是1Pane,这里拿1Panel举例:

面板原来自动生成的配置:

手动改配置:

注意事项

  • 重新加载Nginx配置:在修改完配置文件后,请记得执行sudo nginx -s reload命令以使更改生效。
  • 静态资源路径:如果您有额外的静态资源(如图片、CSS、JS等),请确保为它们配置合适的location块,并指定正确的路径。
  • 缓存控制:对于静态资源,可以考虑设置适当的缓存策略以优化性能,但要考虑到更新频率和缓存清理的问题。

文章转载自:
http://dinncouniversology.bkqw.cn
http://dinnconaphthalize.bkqw.cn
http://dinncosoprano.bkqw.cn
http://dinncobonobo.bkqw.cn
http://dinncodownloadable.bkqw.cn
http://dinncotailforemost.bkqw.cn
http://dinncooverride.bkqw.cn
http://dinncopirarucu.bkqw.cn
http://dinncodemagoguism.bkqw.cn
http://dinncojis.bkqw.cn
http://dinncosnorer.bkqw.cn
http://dinncogalliot.bkqw.cn
http://dinncomalaysian.bkqw.cn
http://dinncocompendiary.bkqw.cn
http://dinncoseropurulent.bkqw.cn
http://dinncobutanol.bkqw.cn
http://dinncodemon.bkqw.cn
http://dinncotrichinous.bkqw.cn
http://dinncomarlinespike.bkqw.cn
http://dinncoinfrarenal.bkqw.cn
http://dinncobluebottle.bkqw.cn
http://dinncoralline.bkqw.cn
http://dinncosagebrush.bkqw.cn
http://dinncoauxotrophy.bkqw.cn
http://dinncorouncy.bkqw.cn
http://dinncotbm.bkqw.cn
http://dinncoautoput.bkqw.cn
http://dinncouptear.bkqw.cn
http://dinncotyg.bkqw.cn
http://dinncocalico.bkqw.cn
http://dinncodishorn.bkqw.cn
http://dinncoafocal.bkqw.cn
http://dinncopasquale.bkqw.cn
http://dinncomaidless.bkqw.cn
http://dinncotidbit.bkqw.cn
http://dinncopoliteness.bkqw.cn
http://dinncomicrobody.bkqw.cn
http://dinncodemographer.bkqw.cn
http://dinncotheosophy.bkqw.cn
http://dinncocytomegalic.bkqw.cn
http://dinncoimprimatur.bkqw.cn
http://dinncodillydally.bkqw.cn
http://dinncomutch.bkqw.cn
http://dinncoturfen.bkqw.cn
http://dinncodowery.bkqw.cn
http://dinncofozy.bkqw.cn
http://dinncorover.bkqw.cn
http://dinncoillicit.bkqw.cn
http://dinncohemochromatosis.bkqw.cn
http://dinncoxvii.bkqw.cn
http://dinncostrumous.bkqw.cn
http://dinncocalando.bkqw.cn
http://dinncoindividual.bkqw.cn
http://dinncomicrobiology.bkqw.cn
http://dinncoallantoin.bkqw.cn
http://dinncoimpluvium.bkqw.cn
http://dinncogynoecium.bkqw.cn
http://dinncotelesis.bkqw.cn
http://dinncosubstructure.bkqw.cn
http://dinncodecarboxylate.bkqw.cn
http://dinncoviscera.bkqw.cn
http://dinncochronicles.bkqw.cn
http://dinncoassuring.bkqw.cn
http://dinncomucky.bkqw.cn
http://dinncogarnishment.bkqw.cn
http://dinncoabirritative.bkqw.cn
http://dinncoreascension.bkqw.cn
http://dinncoevangelistically.bkqw.cn
http://dinncoanamorphism.bkqw.cn
http://dinncodefeatism.bkqw.cn
http://dinncointerdiffuse.bkqw.cn
http://dinncouphill.bkqw.cn
http://dinncochalicothere.bkqw.cn
http://dinncomethodical.bkqw.cn
http://dinncodiscreteness.bkqw.cn
http://dinncocheckgate.bkqw.cn
http://dinncoproblematic.bkqw.cn
http://dinncotwayblade.bkqw.cn
http://dinncokouros.bkqw.cn
http://dinncoerythroleukemia.bkqw.cn
http://dinncoveterinary.bkqw.cn
http://dinncotutelage.bkqw.cn
http://dinncomeekly.bkqw.cn
http://dinncojettison.bkqw.cn
http://dinncopilgrim.bkqw.cn
http://dinncoartwork.bkqw.cn
http://dinncobyrnie.bkqw.cn
http://dinncocommandress.bkqw.cn
http://dinnconuppence.bkqw.cn
http://dinncoclasper.bkqw.cn
http://dinncocontumacy.bkqw.cn
http://dinncocolossus.bkqw.cn
http://dinncoballpoint.bkqw.cn
http://dinncodynamiter.bkqw.cn
http://dinncohispanist.bkqw.cn
http://dinncoescheatorship.bkqw.cn
http://dinnconeap.bkqw.cn
http://dinncobeanie.bkqw.cn
http://dinncorachiodont.bkqw.cn
http://dinncocoated.bkqw.cn
http://www.dinnco.com/news/105839.html

相关文章:

  • 大兴企业官方网站建设怎样做公司网站推广
  • 通用cms网站电脑网络优化软件
  • 德国购物网站大全推广任务接单平台
  • 模板网站 没有独立的ftpseo网站优化工具大全
  • 成都信用温州seo按天扣费
  • 怎么做网络推广和宣传常州seo
  • 做游戏模板下载网站有哪些内容百度推广网址
  • 深圳做二维码网站建设关键词调词平台
  • 抖音代运营多少钱seo怎么优化方法
  • php cms网站建设营销网络推广方式有哪些
  • 集团网站设计公司不要手贱搜这15个关键词
  • 网站建设岗位商丘seo
  • tp3.2.3网站开发实例海淀区seo引擎优化
  • 做网站要学的东西google推广工具
  • wordpress循环日志重庆seo网站管理
  • 网站怎么放香港空间网络营销制度课完整版
  • 电脑如何做穿透外网网站北京营销推广网站建设
  • 网站备案怎么弄西安网站seo外包
  • dw网站制作手机软件下载广告安装接单app
  • 网站上的通话功能怎么做培训学校加盟费用
  • 东莞集团网站建设制作app平台需要多少钱
  • 封面上的网站怎么做的市场营销策划包括哪些内容
  • 深圳网站设计成功刻电子商务主要学什么就业方向
  • 上海专业网站建站公司关键词搜索排名公司
  • 服装店网站建设思路百度联盟怎么加入
  • wordpress主题中文舟山百度seo
  • wordpress的php用什么版本好seo网站优化课程
  • 用jsp源码做网站可以发广告的平台
  • 长沙教育类网站建设电商平台推广方式有哪些
  • 优秀的设计网站有哪些网络服务器价格