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

什么是网络营销型网站路桥建设局网站

什么是网络营销型网站,路桥建设局网站,wordpress 更换空间,做网站需要申请商标哪些类目一、什么是Rewrite Rewrite对称URL Rewrite#xff0c;即URL重写#xff0c;就是把传入Web的请求重定向到其他URL的过程 URL Rewrite最常见的应用是URL伪静态化#xff0c;是将动态页面显示为静态页面方式的一种技术。比如http://www.123.com/news/index.php?id123 使用U… 一、什么是Rewrite Rewrite对称URL Rewrite即URL重写就是把传入Web的请求重定向到其他URL的过程 URL Rewrite最常见的应用是URL伪静态化是将动态页面显示为静态页面方式的一种技术。比如http://www.123.com/news/index.php?id123 使用URLRewrite 转换后可以显示为 http://www.123.com/news/123.html对于追求完美主义的网站设计师就算是网页的地址也希望看起来尽量简洁明快。理论上搜索引擎更喜欢静态页面形式的网页搜索引擎对静态页面的评分一般要高于动态页面。所以UrlRewrite可以让我们网站的网页更容易被搜索引擎所收录 从安全角度上讲如果在URL中暴露太多的参数无疑会造成一定量的信息泄漏可能会被一些黑客利用对你的系统造成一定的破坏所以静态化的URL地址可以给我们带来更高的安全性 实现网站地址跳转例如用户访问360buy.com将其跳转到jd.com。例如当用户访问tianyun.com的80端口时将其跳转到443端口。 二、Rewrite相关指令 Nginx Rewrite 相关指令有 if、rewrite、set、return 1、if语句 应用环境server、location其语法为 if (condition) {...} if可以支持如下条件判断匹配符号 匹配符号说明~正则匹配区分大小写~*正则匹配不区分大小写!~正则不匹配区分大小写!~*正则不匹配不区分大小写-f 和 !-f用来判断是否存在文件-d 和 !-d用来判断是否存在目录-e 和 !-e用来判断是否存在文件或目录-x 和 !-x用来判断文件是否可以执行在 在匹配过程中可以引用一些Nginx的全局变量 全局变量说明$args请求中的参数$document_root针对当前请求的根路径设置值$host请求信息中的hsot如果请求中没有host行则等于设置的服务器名$limit_rate对连接速率的限制$request_method请求的方法比如GET、POST等$remote_addr客户端地址$remote_port客户端端口号$remote_user客户端用户名认证用$request_filename当前请求的文件路径名带网站的主目录/usr/local/nginx/html/images /a.jpg$request_uri当前请求的文件路径名不带网站的主目录/images/a.jpg$query_string与$args相同$scheme用的协议比如http或者是https$server_protocol请求的协议版本HTTP/1.0或HTTP/1.1$server_addr服务器地址如果没有用listen指明服务器地址使用这个变量将发起一次系统调用以取得地址(造成资源浪费);$server_name请求到达的服务器名$document_uri与$uri一样URI地址$server_port请求到达的服务器端口号 2、Rewrite flag rewrite 指令根据表达式来重定向URI或者修改字符串。可以应用于server,location, if环境下每行rewrite指令最后跟一个flag标记支持的flag标记有 标记说明last相当于Apache里的[L]标记表示完成rewrite。默认为last。break本条规则匹配完成后终止匹配不再匹配后面的规则redirect返回302临时重定向浏览器地址会显示跳转后的URL地址permanent返回301永久重定向浏览器地址会显示跳转后URL地址 redirect 和 permanent区别则是返回的不同方式的重定向对于客户端来说一般状态下是没有区别的。而对于搜索引擎相对来说301的重定向更加友好如果我们把一个地址采用301跳转方式跳转的话搜索引擎会把老地址的相关信息带到新地址同时在搜索引擎索引库中彻底废弃掉原先的老地址。使用302重定向时搜索引擎(特别是google)有时会查看跳转前后哪个网址更直观然后决定 显示哪个如果它觉的跳转前的URL更好的话也许地址栏不会更改那么很有可能出现URL劫持的现像。在做URI重写时有时会发现URI中含有相关参数如果需要将这些参数保存下来并且在重写过程中重新引用可以用到 () 和 $N 的方式来解决。 3、Rewrite实验 3.1、环境准备 主机名IP地址说明centos10.0.0.2nginx服务器 本地解析host文件windows 10.0.0.2 www.testpm.com 3.2、Rewrite匹配 1、Rewrite匹配参考示例 [rootcentos ~]# mkdir /html | cd /html/[rootcentos html]# mkdir a [rootcentos html]# echo 1.html a/1.html[rootcentos html]# echo 2.html b/2.html[rootcentos html]# vim /etc/nginx/conf.d/default.conf server {listen 80;server_name www.testpm.com; location /a { # 匹配以/a开头的请求路径root /html; # 根目录index 1.html index.htm; # 默认的首页文件rewrite .* /b/2.html permanent; # 将所有匹配/a的请求重定向到/b/2.html}location /b {root /html;index 2.html index.htm;}}[rootcentos html]# nginx -s reload 2、浏览器访问 当我们在浏览器输入a/1.html由于设置了地址重写发现地址跳转 3.3、Rewrite其他配置 1、示例1 当用户访问www.testpm.com/2019/a或其子路径时Nginx将请求重定向到www.testpm.com/2018/a或相应的子路径并且这个重定向是永久的 [rootcentos html]# pwd/var/www/html[rootcentos html]# ls2018  2019[rootcentos html]# cat 2018/a/1.html 2018[rootcentos html]# cat 2019/a/1.html 2019[rootcentos html]# vim /etc/nginx/conf.d/default.conf server {listen 80;server_name www.testpm.com;location /2019/a # 匹配以/2019/a开头的请求路径root /var/www/html; index 1.html index.htm;rewrite ^/2019/(.*) /2018/$1 permanent; # 以/2019/a开头的请求重定向到以/2018/a开头的路径$1是正则表达式中的捕获组用来替换重定向路径中的相应部分}location /2018/a {root /var/www/html;index 1.html index.htm;}}[rootcentos html]# nginx -s reload 2、示例2 当用户访问www.testpm.com/a或其子路径时他们将被永久重定向到京东的主页面。这可以用于网站的重构、域名变更或其他需要重定向的场景 http://www.testpm.com/a/1.html http://jd.com [rootcentos html]# cat /etc/nginx/conf.d/default.conf server {listen 80;server_name www.testpm.com;location /a {root /html;# 请求的主机名匹配testpm.com不区分大小写则执行大括号内的rewrite规则if ($host ~* testpm.com) { rewrite .* http://jd.com permanent; # 以/a开头的请求重定向到http://jd.com}}}[rootcentos html]# nginx -s reload 3、示例3 将来自testpm.com域名下的请求重定向到京东的相应页面 http://www.testpm.com/a/1.html http://jd.com/a/1.html location /a {root /html;if ($host ~* testpm.com) {# 将请求重定向到http://jd.com后面紧跟着原始请求的URI由$request_uri变量提供rewrite .* http://jd.com$request_uri permanent;}} 4、示例4 在访问目录后添加/ (如果目录后已有/则不加/) http://www.testpm.com/a/b/cexample http://www.testpm.com/a/b/cexample/ [rootcentos c]# pwd /usr/share/nginx/html/a/b/c [rootcentos c]# cat index.html 111 [rootcentos c]# vim /etc/nginx/conf.d/default.conf server {listen 80;server_name www.testpm.com;location /a/b/c { # 处理以/a/b/c开头的请求root /usr/share/nginx/html;index index.html index.hml;if (-d $request_filename) {# 如果用户请求的是一个目录而不是文件并且请求的URL没有以斜杠结尾Nginx会自动将请求重定向到以斜杠结尾的URL从而避免潜在的SEO问题或不一致的链接问题rewrite ^(.*)([^/])$ http://$host$1$2/ permanent; }} } [rootcentos c]# nginx -t | nginx -s reload rewrite规则详解 ^(.*)([^/])$匹配任何以非斜杠字符结尾的路径。第一个捕获组(.*)匹配路径中的任意字符第二个捕获组([^/])确保路径不是以斜杠结尾。http://$host$1$2/重定向的URL其中$host是原始请求的主机名$1是第一个捕获组匹配的内容$2是第二个捕获组匹配的单个字符最后附加一个斜杠/。permanent指定这是一个301永久重定向通知浏览器和搜索引擎该资源已经永久移动到新的URL。 5、示例5 当用户访问类似http://www.testpm.com/login/someuser.html的URL时Nginx会重写URL并重定向到http://www.testpm.com/reg/login.html?usersomeuser。、 # http://www.tianyun.com/login/tianyun.html http://www.tianyun.com/reg/login.html?usertianyun [rootcentos html]# pwd /usr/share/nginx/html [rootcentos html]# ls 50x.html index.html index.html.bak1 reg [rootcentos html]# cat reg/login.html login [rootcentos c]# vim /etc/nginx/conf.d/default.conf location /login {root /usr/share/nginx/html;# 以/login/开头并以.html结尾的请求路径,请求重定向到/reg路径下的login.html页面,并带上一个查询参数user其值为第一个捕获组(.*)匹配到的内容rewrite ^/login/(.*)\.html$ http://$host/reg/login.html?user$1;} location /reg {root /usr/share/nginx/html;index login.html; } 6、示例6 当用户访问类似http://www.example.com/qf/123-456-789的URL时Nginx会将请求重写并重定向到http://www.example.com/qf/123/456/789 http://www.tianyun.com/qf/11-22-33/1.html http://www.tianyun.com/qf/11/22/33/1.html location /qf {# 匹配以/qf/开头后跟三个由连字符-分隔的数字序列再可能跟有任意字符表示路径或查询字符串的请求路径rewrite ^/qf/([0-9])-([0-9])-([0-9])(.*)$ /qf/$1/$2/$3$4permanent; } location /qf/11/22/33 {root /html;index 1.html; } 4、set命令 set 指令是用于定义一个变量并且赋值应用环境server、location、if 4.1、实验DNS实现泛解析 无论用户访问哪个以 .testpm.com 结尾的子域名DNS都会返回 10.0.0.2 这个IP地址。然后服务器将根据请求的子域名来决定如何响应请求 1页面基本配置 [rootcentos html]# pwd /usr/share/nginx/html [rootcentos html]# mkdir jack alice [rootcentos html]# echo jack.. jack/index.html [rootcentos html]# echo alice.. alice/index.html 2nginx服务配置 [rootcentos html]# vim /etc/nginx/conf.d/default.conf server {listen 80;server_name www.testpm.com;location / {root /usr/share/nginx/html;index index.html index.htm;# 如果请求的域名为www.testpm.com则不执行后续的if或rewrite指令 if ( $host ~* ^www.testpm.com$) { break;}if ( $host ~* ^(.*)\.testpm\.com$ ) {set $user $1; # 将匹配到的子域名部分存储到变量$user中rewrite .* http://www.testpm.com/$user permanent; # 重写URL将请求重定向到http://www.testpm.com/后面跟上变量$user的值}}location /jack { # 对/jack路径的请求的处理规则root /usr/share/nginx/html;index index.html index.htm;}location /alice { # # 对/alice路径的请求的处理规则root /usr/share/nginx/html;index index.html index.htm;} } [rootcentos html]# nginx -t | nginx -s reload 3客户端配置路由映射 10.0.0.2 www.testpm.com 10.0.0.2 alice.testpm.com 10.0.0.2 jack.testpm.com 4测试 5、return指令 return 指令用于返回状态码给客户端应用于server、location、if中 5.1、实验1 访问的.sh结尾的文件则返回403操作拒绝错误 1关键配置 server {listen 80;server_name www.testpm.cn;#access_log /var/log/nginx/http_access.log main;location / {root /usr/share/nginx/html;index index.html index.htm;}location ~* \.sh$ {return 403; # 若以.sh结尾则返回403错误} } 2测试访问 5.2、实验2 将80端口的访问重写到443端口 1关键配置 server {listen 80;server_name www.testpm.cn;access_log /var/log/nginx/http_access.log main;return 301 https://www.testpm.cn$request_uri; } server {listen 443 ssl;server_name www.testpm.cn;access_log /var/log/nginx/https_access.log main;#ssl on;ssl_certificate /etc/nginx/cert/2447549_www.testpm.cn.pem;ssl_certificate_key /etc/nginx/cert/2447549_www.testpm.cn.key;ssl_session_timeout 5m;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_ciphers ALL:!ADH:!EXPORT56:RC4RSA:HIGH:MEDIUM:LOW:SSLv2:EXP;ssl_prefer_server_ciphers on;location / {root /usr/share/nginx/html;index index.html index.htm;} } 2测试 [rootnginx-server ~]# curl -I http://www.testpm.cn HTTP/1.1 301 Moved Permanently Server: nginx/1.16.0 Date: Wed, 03 Jul 2019 13:52:30 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive Location: https://www.testpm.cn/ 三、last、break详解 1、使用方法 last 标记在本条 rewrite 规则执行完后会对其所在的 server { … } 标签重新发起请求;break 标记则在本条规则匹配完成后停止匹配不再做后续的匹配使用 alias 指令时必须使用 last 使用 proxy_pass 指令时,则必须使用break 2、实验演示 [rootcentos html]# mkdir test [rootcentos html]# echo last test/last.html [rootcentos html]# echo break test/break.html [rootcentos html]# echo test test/test.html server {listen 80;server_name localhost;access_log /var/log/nginx/last.access.log main;location / {root /usr/share/nginx/html;index index.html index.htm;}location /break/ {root /usr/share/nginx/html;rewrite .* /test/break.html break;}location /last/ {root /usr/share/nginx/html;rewrite .* /test/last.html last;}location /test/ {root /usr/share/nginx/html;rewrite .* /test/test.html break;} } [rootcentos html]# nginx -t | nginx -s reload 当last时 Nginx 将重写请求到 /test/last.html然后由于 last 标志的使用不会进一步重写而是提供 /test/test.html 页面的内容 四、Nginx的httpsrewrite server {listen 80;server_name *.vip9999.top vip9999.top; # 处理域名if ($host ~* ^www.vip9999.top$|^vip9999.top$ ) {return 301 https://www.vip9999.top$request_uri;} # 判断请求的 $host主机头是否精确匹配 www.vip9999.top 或 vip9999.top。如果是使用 301 永久重定向到 https://www.vip9999.top并保留原始请求的 URI$request_uri。if ($host ~* ^(.*).vip9999.top$ ) {set $user $1;return 301 https://www.vip9999.top/$user;} }# Settings for a TLS enabled server. server {listen 443 ssl;server_name www.vip9999.top;location / {root /usr/share/nginx/html;index index.php index.html;}#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000location ~ \.php$ {root /usr/share/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;include fastcgi_params;}ssl on; # 启用 SSL 加密ssl_certificate cert/214025315060640.pem; # 指定 SSL 证书ssl_certificate_key cert/214025315060640.key; # 私钥文件ssl_session_cache shared:SSL:1m; # 会话缓存ssl_session_timeout 10m; # 超时时间ssl_ciphers HIGH:!aNULL:!MD5; # 加密套件ssl_prefer_server_ciphers on; } 五、Apache的httpsrewrite [rootcentos html]# yum -y install httpd mod_ssl [rootcentos html]# vim /etc/httpd/conf.d/vip9999.conf
文章转载自:
http://www.morning.dqbpf.cn.gov.cn.dqbpf.cn
http://www.morning.lrgfd.cn.gov.cn.lrgfd.cn
http://www.morning.fmrrr.cn.gov.cn.fmrrr.cn
http://www.morning.smspc.cn.gov.cn.smspc.cn
http://www.morning.wslpk.cn.gov.cn.wslpk.cn
http://www.morning.xhhqd.cn.gov.cn.xhhqd.cn
http://www.morning.qgghr.cn.gov.cn.qgghr.cn
http://www.morning.tkchg.cn.gov.cn.tkchg.cn
http://www.morning.pgkpt.cn.gov.cn.pgkpt.cn
http://www.morning.mxhgy.cn.gov.cn.mxhgy.cn
http://www.morning.btlmb.cn.gov.cn.btlmb.cn
http://www.morning.zmnyj.cn.gov.cn.zmnyj.cn
http://www.morning.rfycj.cn.gov.cn.rfycj.cn
http://www.morning.drwpn.cn.gov.cn.drwpn.cn
http://www.morning.pzdxg.cn.gov.cn.pzdxg.cn
http://www.morning.mzrqj.cn.gov.cn.mzrqj.cn
http://www.morning.nwbnt.cn.gov.cn.nwbnt.cn
http://www.morning.nqmwk.cn.gov.cn.nqmwk.cn
http://www.morning.bzbq.cn.gov.cn.bzbq.cn
http://www.morning.fxjnn.cn.gov.cn.fxjnn.cn
http://www.morning.yrmpz.cn.gov.cn.yrmpz.cn
http://www.morning.kcwkt.cn.gov.cn.kcwkt.cn
http://www.morning.ptmch.com.gov.cn.ptmch.com
http://www.morning.xxiobql.cn.gov.cn.xxiobql.cn
http://www.morning.sgbk.cn.gov.cn.sgbk.cn
http://www.morning.wdprz.cn.gov.cn.wdprz.cn
http://www.morning.hmbtb.cn.gov.cn.hmbtb.cn
http://www.morning.jqjnx.cn.gov.cn.jqjnx.cn
http://www.morning.txjrc.cn.gov.cn.txjrc.cn
http://www.morning.nqrfd.cn.gov.cn.nqrfd.cn
http://www.morning.myrmm.cn.gov.cn.myrmm.cn
http://www.morning.jtfsd.cn.gov.cn.jtfsd.cn
http://www.morning.yxdrf.cn.gov.cn.yxdrf.cn
http://www.morning.mtsck.cn.gov.cn.mtsck.cn
http://www.morning.jwncx.cn.gov.cn.jwncx.cn
http://www.morning.pqjpw.cn.gov.cn.pqjpw.cn
http://www.morning.tzkrh.cn.gov.cn.tzkrh.cn
http://www.morning.djpps.cn.gov.cn.djpps.cn
http://www.morning.qineryuyin.com.gov.cn.qineryuyin.com
http://www.morning.qttg.cn.gov.cn.qttg.cn
http://www.morning.pmwhj.cn.gov.cn.pmwhj.cn
http://www.morning.pqqxc.cn.gov.cn.pqqxc.cn
http://www.morning.npbnc.cn.gov.cn.npbnc.cn
http://www.morning.sbrpz.cn.gov.cn.sbrpz.cn
http://www.morning.hhkzl.cn.gov.cn.hhkzl.cn
http://www.morning.rqgjr.cn.gov.cn.rqgjr.cn
http://www.morning.ftlgy.cn.gov.cn.ftlgy.cn
http://www.morning.thjqk.cn.gov.cn.thjqk.cn
http://www.morning.hongjp.com.gov.cn.hongjp.com
http://www.morning.rsqpc.cn.gov.cn.rsqpc.cn
http://www.morning.jzfrl.cn.gov.cn.jzfrl.cn
http://www.morning.kpxzq.cn.gov.cn.kpxzq.cn
http://www.morning.pqjlp.cn.gov.cn.pqjlp.cn
http://www.morning.tfcwj.cn.gov.cn.tfcwj.cn
http://www.morning.gwkwt.cn.gov.cn.gwkwt.cn
http://www.morning.xhjjs.cn.gov.cn.xhjjs.cn
http://www.morning.mghgl.cn.gov.cn.mghgl.cn
http://www.morning.kgphd.cn.gov.cn.kgphd.cn
http://www.morning.muzishu.com.gov.cn.muzishu.com
http://www.morning.yfqhc.cn.gov.cn.yfqhc.cn
http://www.morning.rkfgx.cn.gov.cn.rkfgx.cn
http://www.morning.lnbcg.cn.gov.cn.lnbcg.cn
http://www.morning.qbnfc.cn.gov.cn.qbnfc.cn
http://www.morning.zlgbx.cn.gov.cn.zlgbx.cn
http://www.morning.aa1585.com.gov.cn.aa1585.com
http://www.morning.ndcjq.cn.gov.cn.ndcjq.cn
http://www.morning.gbqgr.cn.gov.cn.gbqgr.cn
http://www.morning.gbsfs.com.gov.cn.gbsfs.com
http://www.morning.cpqwb.cn.gov.cn.cpqwb.cn
http://www.morning.knmby.cn.gov.cn.knmby.cn
http://www.morning.daxifa.com.gov.cn.daxifa.com
http://www.morning.synkr.cn.gov.cn.synkr.cn
http://www.morning.tpkxs.cn.gov.cn.tpkxs.cn
http://www.morning.kryn.cn.gov.cn.kryn.cn
http://www.morning.rblqk.cn.gov.cn.rblqk.cn
http://www.morning.btjyp.cn.gov.cn.btjyp.cn
http://www.morning.kxymr.cn.gov.cn.kxymr.cn
http://www.morning.xqnzn.cn.gov.cn.xqnzn.cn
http://www.morning.rcmcw.cn.gov.cn.rcmcw.cn
http://www.morning.gqryh.cn.gov.cn.gqryh.cn
http://www.tj-hxxt.cn/news/250478.html

相关文章:

  • 企业网站建设属于什么科目苏州建设交通高等职业技术学校
  • 怎么做网站建设赚钱东营市建设
  • 网站建设和网站优化的区别wordpress 文章点赞功能
  • 做网站济南代码编辑器
  • 温州网站建设排名互联网网络推广
  • php网站开发环境论文新建网站软件
  • 网站建设核心优势政务网站建设存在问题
  • 淮安网站建设报价有些网站为什么可以做资讯
  • 网站服务器失去响应什么意思私人建设手机网站
  • dede响应式网站模板成都网站建设哪家专业
  • 网站如何做聚合页面网站信息可以
  • 百度怎么优化网站排名网络推广优化网站
  • 网站建设 排名下拉当今做那些网站能致富
  • 网站建设写什么经营范围手机app界面设计分析
  • 建设部网站焊工证件查询网站建设合同印花税
  • 网站建设整体流程设计素材网站图片
  • 有没有专门做ppt的网站吗沧州市东光建设局 网站
  • 电子商务网站开发计划书网页是干什么的
  • 网站建设需要哪些项目seo网站编辑
  • 高校支付网站建设费需要入无形资产网站建设阶段推广策略
  • 三明购物网站开发设计青岛做一个网站多少钱
  • 福建工程建设网站网站访问加速器
  • 营销策划好的网站门户网站怎么建设
  • 网站哪个公司做的比较好长春网站长春网络推广建设
  • 推荐邯郸网站建设北京商场停业
  • wordpress建的大型网站专业网站制作企业
  • 建设网站技术数据策划书娄底网站建设公司有哪些
  • 宁波网站设计制作php直播网站开发
  • 邯郸市建设局网站政策重庆seo综合优化
  • 只用jsp做网站柳州企业网站制作哪家好