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

做网站的工作叫什么杭州关键词推广优化方案

做网站的工作叫什么,杭州关键词推广优化方案,会员中心网站模板,惠喵WordPressNginx重定向 location 匹配 location匹配的就是后面的URL /WordPress 192.168.118.10/wordpress location匹配的分类和优先级 1.精确匹配 location/对字符串进行完全匹配,必须完全符合2.正则匹配 ^~ 前缀匹配,以什么为开头~ 区分大小写的匹配~* 不区分大小写!~: 区分大小…

Nginx重定向

location 匹配

location匹配的就是后面的URL /WordPress

192.168.118.10/wordpress

location匹配的分类和优先级

1.精确匹配

location=/对字符串进行完全匹配,必须完全符合

2.正则匹配

^~ 前缀匹配,以什么为开头~ 区分大小写的匹配~* 不区分大小写!~: 区分大小写的取反!~*: 不区分大小写的取反

3.一般匹配

location /字符串

优先级总结

location = 完整路径 > location ^~ > (location ~ location~*) >location /部分起始位置 > location /

实际网站中的使用规则

第一个规则,网站首页一般用精确=/
location = / {root html;index index.html index.htm index.php;}第二个规则,处理静态请求的页面
location ^~ /static/ {root /web/static/;index index.html index.htm;
}
用来匹配静态页面 访问图片或者是指定的后缀名
location ~* \.(jpg|gif|png|jpeg|css)$ {root /web/pictures/;index index.html index.htm;}第三个规则,一般是通用规则,用来转发.php.js为后缀的动态请求到后端服务器(数据库)
location / {proxy_pass
}
转发后端请求和负载均衡

rewrite重定向:

rewrite就是把当前访问的页面跳转到其他页面

rewrite的工作方式:通过nginx的全局变量或者自定义变量,结合正则表达式和标志位实现url的重定向

nginx的变量

$uri 客户端请求的uri地址
$host: 请求的主机名
$http_user_agent:客户端请求的浏览器和操作系统
$http_referer:请求头的referer信息,表示当前页面来源的uri
$remote_addr:客户端的ip地址
$remote_port:客户端的端口号
$server_addr:服务端的ip地址
$server_port:服务端的端口号
$request_method:获取客户端请求的方法
$scheme:请求的协议,要么是http,要么是https
x_forwarded_for: 用来获取请求头当中,客户端的真实ip地址(代理服务器添加,在代理服务器当中,指示客户端的ip地址)
x-Real-ip:客户端真实的ip地址nginx.conf
proxy_set_header X-Real-IP $remote_addr (加上这一字段,客户端的真实ip地址就会传递给后端数据库)

vim nginx.conf

systemctl restart nginx

nginx标志位

flg

permanent:永久重定向,返回码是301,浏览器地址栏会显示跳转后的URL地址
redirect: 临时重定向,返回码是302浏览器地址栏会显示跳转后的URL地址
break:	永久重定向,返回码也是301,但是他匹配到规则之后,不会再向下匹配其他规则,URI也不会发生变化
last:	重定向,但是会继续向下匹配其他的location规则

rewrite的执行顺序:

1.server模块的rewrite优先级最高
2.匹配location的规则
3.执行选定的location规则

rewrite的语法

rewrite 正则表达式 跳转后的内容 标志位;
mkdir test1
mkdir xy102
echo 123 > test1/index.html
echo 456 > xy102/index.html
vim nginx.conf
location /{root html;rewrite /test1/(.*) /xy102/$1 permanent;#$1就是访问过来的时候,捕获组
}

会报500错

基于域名进行跳转

老的不用了,但是依然能够访问,通通跳转到新的域名

[root@test1 conf]# vim nginx.confserver {listen       80;server_name  www.xy102.com;charset utf-8;#access_log  logs/host.access.log  main;location / {root   html;if ($host = 'www.xy102.com') {rewrite ^/(.*)$ http://www.cj.com/$1 permanent;}index index.html;}
#其他代码
:wq
[root@test1 conf]# systemctl restart nginx.service 
[root@test1 conf]# vim /etc/hosts
192.168.118.10 www.xy102.com www.cj.com
#虚拟机浏览器http://www.cj.com/

基于客户端ip进行跳转

公司有新业务上线,测试阶段,其他的ip只能显示维护中,只有192.168.118.10能正常访问

[root@test1 conf]# vim nginx.confserver {listen       80;server_name  www.xy102.com;charset utf-8;#access_log  logs/host.access.log  main;set $rewrite true;#设置一个变量名,rewrite,值是true#来进行判断ip是否是合法ipif ( $remote_addr = "192.168.118.10" ){set $rewrite false;}if ( $rewrite = true ){rewrite (.+) /error.html;#重定向,192.168.118.10/error.html}location = /error.html {root html;}location / {root   html;if ($host = 'www.xy102.com') {rewrite ^/(.*)$ http://www.cj.com/$1 permanent;}index index.html;}
#其他代码
:wq
[root@test1 conf]# systemctl restart nginx.service 
[root@test1 conf]# cd ..
[root@test1 conf]# cd html/
[root@test1 html]# echo "网页维护中!" > error.html
[root@test1 html]# vim /etc/hosts
192.168.118.10 www.xy102.com www.cj.com
#虚拟机浏览器http://www.cj.com/

t nginx.service
[root@test1 conf]# cd …
[root@test1 conf]# cd html/
[root@test1 html]# echo “网页维护中!” > error.html
[root@test1 html]# vim /etc/hosts
192.168.118.10 www.xy102.com www.cj.com
#虚拟机浏览器http://www.cj.com/


http://www.dinnco.com/news/57422.html

相关文章:

  • 市委宣传部长分管哪些单位seo营销方案
  • 单页网站怎么制作百度帐号
  • 北京建设信源公司网站seo优化公司哪家好
  • 郴州市住房建设局门户网站域名免费注册
  • 有域名之后怎么做网站怎么开个人网站
  • 做网站做小程序推广优惠活动推广文案
  • 做商城网站的流程介绍营销网站的建造步骤
  • ui网页设计师职责能力唐山百度搜索排名优化
  • 如何做网站计数器比较经典的营销案例
  • 网站建设进度表 下载宁波抖音seo搜索优化软件
  • 制作网站设计的公司黄页引流推广网站入口
  • 申请免费个人网站空间谷歌推广
  • 建立公司网站需要什么微信推广怎么弄
  • c 网站开发的书籍企业查询网站
  • 网站基础建设强化属地管理责任免费观看短视频的app软件推荐
  • b站推广网站2023年app推广30元一单
  • 网站推广见效快的方法seo教育
  • 个人业务网站免费制作竞价网
  • 上海 网站工作室交换友链
  • 自己有主机怎么做论坛网站磁力珠
  • 手机微信网页版登录网站seo优化多少钱
  • 眼科医院网站设计怎么做6seo建设招商
  • 莱芜吧莱芜贴吧seo修改器
  • seo发外链网站搜多多搜索引擎入口
  • 网站怎样投放广告位百度明星人气排行榜
  • 做网站 租服务器吗黑帽seo培训
  • 建设项目经济评价网站教育培训机构官网
  • 做网站的软件叫什么百度网盘app手机版
  • 企业网站建设总结抖音怎么推广
  • 网站开发与推广最近新闻