13397158231   jevian_ma@worldflying.cn

开发企业官网常用伪静态规则(nginx与apache)

2020-05-18 22:42:16

对于企业展示网站,或是产品展示网站,SEO是非常重要的,对于搜索引擎喜欢静态页面高于动态页面这一点,也是得到公认的。但是静态页面存在的问题,如内容修改不方便等,也是网站维护人员十分头疼的问题。在这样的矛盾下,伪静态技术诞生了。所谓伪静态,就是假的静态页面,但是使用的是类似htm或是html等的后缀的链接展示。在这些链接背后,是动态网站技术,例如php等。

下面小沃就告诉大家小沃最长使用的两个web服务器,nginx与apache的伪静态规则。

nginx:

rewrite ^/index.html$ /index.php;
rewrite ^/(\w+).html$ /index.php?do=$1;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11&$12=$13;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11&$12=$13&$14=$15;
rewrite ^/(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ /index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11&$12=$13&$14=$15&$16=$17;

apache:

RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^(\w+).html$ index.php?do=$1
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11&$12=$13
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11&$12=$13&$14=$15
RewriteRule ^(\w+)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*)-(\w+)-([^\-\#\%\?\&]*).html$ index.php?do=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11&$12=$13&$14=$15&$16=$17


文章作者:沃航科技

优秀产品推荐:物联网IO控制器

上一篇:一文教会你如何交叉编译openssl

下一篇:利用阿里云的域名解析openapi实现ddns服务功能

联系我们

  • 地址:武汉市东湖高新开发区光谷总部国际1栋2412室
  • QQ:932773931
  • 电话:027-59761089-806
  • 手机:13397158231
  • 邮箱:jevian_ma@worldflying.cn