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

长沙网站设计哪家好深圳建站公司告诉你十个建站步骤

长沙网站设计哪家好,深圳建站公司告诉你十个建站步骤,网站开发视频代码,网站开发的开发工具目录 一、匹配规则 1.基础匹配 2.精确匹配 3.前缀匹配 4.正则表达式匹配 二、优先级顺序 三、示例 1.精确匹配 2.前缀匹配 3.正则匹配 4.默认匹配 第一种情况#xff1a;proxy_pass最后面没有斜杠,匹配路径有斜杠(/bbb/) 第二种情况#xff1a; proxy_pass最后面…目录 一、匹配规则 1.基础匹配 2.精确匹配 3.前缀匹配 4.正则表达式匹配 二、优先级顺序 三、示例 1.精确匹配 2.前缀匹配 3.正则匹配 4.默认匹配 第一种情况proxy_pass最后面没有斜杠,匹配路径有斜杠(/bbb/) 第二种情况 proxy_pass最后面有斜杠 “/”匹配路径也有斜杠(/bbb/) 第三种情况proxy_pass后面还有其他路径但是最后没有 “/” 匹配路径也有斜杠(/bbb/)  第四种情况 proxy_pass后面还有其他路径但是最后有 “/” 匹配路径也有斜杠(/bbb/)  第五种情况location匹配路径末尾没有 “/”proxy_pass后面也没有“/” 一、匹配规则 1.基础匹配 location / { ... }这是最基本的匹配匹配所有请求。因为它没有指定具体的文件或目录所以通常作为后备选项出现。 2.精确匹配 location /exact/path { ... }精确匹配这个路径。如果请求的 URI 完全等于 /exact/path则使用这个 location 块的配置处理此请求。这具有最高的优先级。 3.前缀匹配 location /prefix/ { ... }前缀匹配请求的 URI 的开始部分。如果请求的 URI 以 /prefix/ 开始这个 location 块将被用来处理请求。location ^~ /prefix/ { ... }前缀匹配但它会停止正则表达式匹配即使正则表达式可能会更具体匹配。如果该 location 匹配Nginx 不会考虑之后的正则 location 块。 4.正则表达式匹配 location ~ /regex/ { ... }大小写敏感的正则匹配。location ~* /regex/ { ... }大小写不敏感的正则匹配。location / { ... } 正则表达式匹配会在普通字符串前缀匹配后进行。如果有多个正则表达式 location 都匹配请求则使用第一个匹配的 location 块。 二、优先级顺序 Nginx 处理请求时 location 匹配的优先级顺序如下 首先进行精确匹配 location 其次按文件中出现顺序匹配所有正则表达式 location ~ 和 location ~*然后进行最长的前缀匹配 location ^~最后是通常的前缀匹配 location /prefix/如果前面的匹配都没有找到就使用默认的 location / 三、示例 1.精确匹配 server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;location /test.html {root /usr/share/nginx/html;}location /test.html {#通过 root 路径会将条件拼接进来root /var/www/html;index index.html;}error_page 404 /404.html; location /404.html {root /usr/share/nginx/test_html;}error_page 500 502 503 504 /50x.html;location /50x.html {} } # 第一个和第二个location匹配条件一样都是/test.html # 但第二个为精准匹配到静态路径因此第一个不会执行会执行第二个。server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;location /test.html {#通过alias指定路径无需拼接条件#alias指定的路径结尾要加“/”alias /usr/share/nginx/test_html/;}error_page 404 /404.html; location /404.html {root /usr/share/nginx/test_html;}error_page 500 502 503 504 /50x.html;location /50x.html {} }# 指定静态资源路径除了使用关键字root还可以用alias。 # 那么root和alias的区别是什么 # 用root属性指定的值是要加入到最终路径中的匹配条件会拼接到路径中 # 用alias属性指定的值不需要加入到最终路径中# 请求的条件为test.html通过root指定的路径为/usr/share/nginx/test_html因此在匹配的时候这个路径下就必须要有test.html这个文件才可以否则就会找不到而报错如果用alias那么通过浏览器进行请求的时候alias也是指定到/usr/share/nginx/test_htm路径下但是会匹配默认的index.html而无须强制匹配test.html。# 不能使用””来进行精确匹配 2.前缀匹配 server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;location ^~ /a/ {root /data/webroot/;}location ^~ /a/www/ {root /data/webroot/;}}# 当请求为 http://welcome.com/a/ 时访问 /data/webroot/a/ 下的index.html文件 # 当请求为 http://welcome.com/a/www/ 时访问 /data/webroot/a/www/ 下的index.html文件 # 如果^~匹配成功了那么表示阻断正则表达式不再进行正则匹配 3.正则匹配 # 正则表达式匹配大小写敏感 server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;location ~ \.(gif|jpg|png)$ {root /var/www/images;}error_page 404 /404.html; location /404.html {root /usr/share/nginx/test_html;}error_page 500 502 503 504 /50x.html;location /50x.html {} } # 正则表达式匹配大小写不敏感 server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;location ~* \.(css|js)$ {root /var/www/assets;}error_page 404 /404.html; location /404.html {root /usr/share/nginx/test_html;}error_page 500 502 503 504 /50x.html;location /50x.html {} } 4.默认匹配 第一种情况proxy_pass最后面没有斜杠,匹配路径有斜杠(/bbb/) server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;#默认匹配location /bbb/ {proxy_pass http://127.0.0.1:9190;proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}# proxy_pass最后面没有斜杠“/”此时通过浏览器请求http://10.9.2.248/bbb/ # 那么实际访问的地址就是 http://127.0.0.1:9190/bbb/会将匹配路径/bbb一起加过去。 第二种情况 proxy_pass最后面有斜杠 “/”匹配路径也有斜杠(/bbb/) server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;#默认匹配location /bbb/ {proxy_pass http://127.0.0.1:9190/;proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}} # proxy_pass最后面有斜杠”/”此时通过浏览器请求http://10.9.2.248/bbb/ # 那么实际访问的地址就是 http://127.0.0.1:9190会将/bbb抛弃的 第三种情况proxy_pass后面还有其他路径但是最后没有 “/” 匹配路径也有斜杠(/bbb/)  server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;#默认匹配location /bbb/ {proxy_pass http://127.0.0.1:9190/ccc;proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;} } # 通过浏览器访问http://10.9.2.248/bbb/index.html # 实际请求的是http://127.0.0.1/index.html # 位置是默认路径下不是ccc路径下 # 如果proxy_pass的路径为/ccc/ddd那么实际请求的就是ccc路径下的cccindex.html 第四种情况 proxy_pass后面还有其他路径但是最后有 “/” 匹配路径也有斜杠(/bbb/)  server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;#默认匹配location /bbb/ {proxy_pass http://127.0.0.1:9190/ccc/;proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;} } # 通过浏览器访问http://10.9.2.248/bbb/index.html # 实际访问的是http://127.0.0.1/ccc/index.html 第五种情况location匹配路径末尾没有 “/”proxy_pass后面也没有“/” server {listen 80;listen [::]:80;server_name welcome.com;access_log /etc/nginx/vhost/logs/access_welcome.log;error_log /etc/nginx/vhost/logs/error_welcome.log;#默认匹配location /bbb {proxy_pass http://127.0.0.1:9190;proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;} } # 匹配路径和proxy_pass后都没有”/” # 访问http://10.9.2.248/bbb # 默认将请求到http://127.0.0.1:9190/bbb/index.html的内容
http://www.zqtcl.cn/news/152371/

相关文章:

  • 贾汪徐州网站开发门户网站解决方案
  • 网站如何做淘宝支付个人注册商标步骤
  • 书香校园网站建设网站排名下降了怎么办
  • 观音桥网站建设湖南省建设银行网站官网
  • 信阳网站建设找汉狮搭建网站知识
  • 企业门户网站用户类型商务信息网
  • 深圳网站设计廊坊公司深圳ui设计培训班
  • 为什么网站需要维护帮人推广注册app的平台
  • 网站开发岗位要求服务好的做培训网站
  • 宁波制作网站企业有哪些学网页设计需要什么学历
  • 网站建设公司墨子网络百度域名续费
  • 琪觅公司网站开发中文网页开发工具
  • 教育网站制作设计成都网络营销公司
  • 怎么查看一个网站页面的seo优化情况网站建站建设首选上海黔文信息科技有限公司2
  • 威海网站建设价格深圳优美网络科技有限公司
  • 做网站用什么系统建设网站投资多少
  • 凡科建站官网 网络服务抚顺 网站建设
  • 学校网站的建设方案西安企业seo外包服务公司
  • 建设租车网站深圳ww
  • 推广网络网站潜江资讯网一手机版
  • 凡科网站自己如何做毕设 做网站
  • 一起做网站逛市场百度权重查询网站
  • 专业网站优化推广网站核查怎么抽查
  • 牡丹江站salong wordpress
  • 网站建设公司做网站要多少费用有哪些外国网站国内可以登录的
  • 天津建站平台网页制作免费的素材网站
  • 建设网站需要专业哪个企业提供电子商务网站建设外包
  • 公司网站建设及维护网站建设思维
  • 那个网站可以学做西餐17做网站广州沙河
  • 品牌网站建设哪里好京东网站建设案例