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

中山住房和建设局工程交易网站总结什么是网络营销

中山住房和建设局工程交易网站,总结什么是网络营销,怎么查一个公司的网址,设计分公司加盟前端部署单页应用时在nginx上经常用到try_files指令#xff0c;而对于try_files并不知道其所以然#xff0c;所以花时间整理总结如下。 Syntax: try_files file … uri; try_files file … code; Default: — Context: server, location 根据root和alias指令提供的值按照tr…前端部署单页应用时在nginx上经常用到try_files指令而对于try_files并不知道其所以然所以花时间整理总结如下。 Syntax: try_files file … uri; try_files file … code; Default: — Context: server, location 根据root和alias指令提供的值按照try_files指令值的顺序查找对应文件是否存在。可以通过以斜杠结(/)尾的文件名让try_files查找文件夹是否存在例如“$uri/”。try_files指令提供的file都不存在那么就会发起内部重定向到uri。如果可以找到file以找到的第一个file作为条件继续处理当前请求。 上面的描述没有错但是不够具体刚看这个描述我有如下问题 对于file和uritry_files的处理有什么不同try_files的处理流程在nginx中具体是什么样的查找到文件和文件之后呢什么是内部重定向 准备工作 开启nginx的debug模式 确保 nginx -V 输出有 configure arguments: --with-debug。如果没有需要重新编译安装ngxin具体方法借助搜索引擎吧。 在http模块下添加配置 http {# 设置错误日志地址和日志级别为debugerror_log path/to/log/file debug;}准备验证环境 准备网站根目录 /path/to/www/添加测试nginx服务server {listen 8080;root /path/to/www/;location / {try_files /helloworld.html /hello/ /internalRedirect;}location /internalRedirect {return 200 internalRedirect;} }准备知识 nginx 配置文件执行是分为11个阶段按照顺序执行的try_files流程涉及到的阶段有find-config、try_files和content这三个阶段server-rewrite、rewrite、post-write等剩余阶段此处省略。 find-config阶段主要根据请求的uri在nginx文件中寻找匹配的location块。 try_files阶段主要执行try_files指令。 content阶段上面的nginx服务只涉及到默认的模块nginx_index、nginx_autoindex和nginx_static。 try_files指令解析 当请求匹配中 location / 时try_files会去找文件 /path/to/www/helloworld.html没找到会继续找/path/to/www/hello文件夹都没找到最后会内部重定向到 /internalRedirect。 curl http://localhost:8080/返回 internalRedirect截取部分debug日志文件。 [debug] 17945#0: *2 trying to use file: /helloworld.html /path/to/www/helloworld.html [debug] 17945#0: *2 trying to use dir: /hello /path/to/www/hello [debug] 17945#0: *2 trying to use file: /internalRedirect /path/to/www/internalRedirect [debug] 17945#0: *2 internal redirect: /internalRedirect? [debug] 17945#0: *2 rewrite phase: 1 [debug] 17945#0: *2 test location: / [debug] 17945#0: *2 test location: internalRedirect [debug] 17945#0: *2 using configuration /internalRedirectnginx执行顺序是先执行findConfig匹配和$uri合适location块配置才会执行try_files指令当try_files使用内部重定向的时候请求的处理流程会被回退到findConfig阶段重新使用/internalRedirect重新匹配location。这个重定向和外部重定向http的301不一样它并不会引起浏览器地址栏的url的修改所以被称为内部重定向。 当找到 /helloworld 之后try_files指令会重写uri的值当执行到content阶段后会依据新的uri的值当执行到content阶段后会依据新的uri的值当执行到content阶段后会依据新的uri值获取对应的静态文件。 在/path/to/www/文件夹下添加helloworld.html文件其内容是hello world。 在ngxin配置中添加 add_header header_uri $uri; curl -i http://localhost:8080/ # -i 会展示响应头返回 HTTP/1.1 200 OK ... header_uri: /helloworld.htmlhello world截取部分log文件日志 [debug] 18875#0: *1 trying to use file: /helloworld.html /path/to/www/helloworld.html [debug] 18875#0: *1 try file uri: /helloworld.html ... [debug] 18875#0: *1 http filename: /path/to/www/helloworld.html当文件夹hello存在try_file会将$uri修改为 /hello 接着给content阶段的模块处理。 删除上一步骤的helloworld.html文件。 curl -i http://localhost:8080/ # -i 会展示响应头返回 HTTP/1.1 301 Moved Permanently ... header_uri: /hellohtml headtitle301 Moved Permanently/title/head body centerh1301 Moved Permanently/h1/center hrcenternginx/1.23.0/center /body /html截取部分log文件日志 [debug] 18875#0: *2 trying to use file: /helloworld.html /Users/zhou/nginx_web/helloworld.html [debug] 18875#0: *2 trying to use dir: /hello /Users/zhou/nginx_web/hello [debug] 18875#0: *2 try file uri: /hello [debug] 18875#0: *2 http filename: /Users/zhou/nginx_web/hello [debug] 18875#0: *2 http static fd: -1 [debug] 18875#0: *2 http dir [debug] 18875#0: *2 http finalize request: 301, /hello? a:1, c:1为什么try_files寻找文件夹的时候需要把指令值/hello/改成/hello我理解末尾的斜杠只是表示try_files这个名字是一个文件夹名所以找的时候把末尾的斜杠去掉了如果想要$uri被赋值的时候带上末尾的斜杠可以 try_files /helloworld.html /hello// /internalRedirect可以给他多加一个斜杠。 参考 agentzh 的 Nginx 教程版本 2020.03.19 Nginx文档try_files指令
http://www.pierceye.com/news/32613/

相关文章:

  • 广告模板网站wordpress do action
  • 网站备案期间能使用吗做DJ网站违法吗
  • 网站设计的流程是什么做跨境电商网站报价
  • 上饶做网站品牌营销策划服务
  • 外贸没有公司 如何做企业网站?成品小说网站源码
  • 贵阳市观山湖区网站建设做网站教程
  • 织梦网站安装教程视频教程网站如何做才能被360收录
  • 网站后台系统功能哈尔滨快照优化
  • 高埗做网站wordpress the7下载
  • 常德网站优化推广wordpress网页聊天工具
  • 网站模板 chinazwordpress app 接口
  • 房产网站做那个比较好腾讯企业邮箱域名格式
  • flash企业网站淄博网站公司电话
  • 有哪些做平面设计好的网站有哪些内容莱芜网络公司
  • 做网站下载什么软件网站建设大量定制阶段
  • 做外贸网站设计上需要注意什么中国建筑工业出版社
  • 建设网站如果赚钱网站设计配色方案
  • 中石化第四建设公司 网站Wordpress插件完全删除
  • 有没有做海报的网站推荐交易所网站建设教程
  • 免费建站网站排名建设网站用户名
  • 郑州网站建设与设计网站后台怎样批量上传
  • 别人在百度冒用公司旗号做网站门户网站开发 项目实施方案
  • 国外 平面设计 网站舟山企业网站建设
  • 社团建设制作网站费用会计科目湛江高端网站开发
  • 江苏省建设教育协会网站首页做黑网站
  • 在网站做推广要钱吗网络运营者
  • 大学生创新创业网站建设申报书网站建设实施计划包括
  • 呼伦贝尔市住房和城乡建设局网站桥头镇做网站
  • 小网站源码明光网站
  • 蓝色网站配色方案网站做好了怎么和域名