用Phpmywind开发的城市分站的Apache和Nginx伪静态规则对比。
Apache下的规则如下:
# 将 RewriteEngine 模式打开
RewriteEngine On
# 修改以下语句中的 / 改为您的系统目录地址,如果程序放在根目录中则无需修改
RewriteBase /
# Rewrite 系统规则请勿修改
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^index.html$ index.php
RewriteRule ^city.html$ city.php
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/index.html$ $1/index.php
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([a-z]+)\/(.*).php$ $2.php
RewriteRule ^([a-z]+)\/$ $1\/index.php
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/about-([0-9]+)-([0-9]+)\.html$ $1/about.php?cid=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/news-([0-9]+)-([0-9]+)\.html$ $1/news.php?cid=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/newsshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/newsshow.php?cid=$2&id=$3&page=$4
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/product-([0-9]+)-([0-9]+)\.html$ $1/product.php?cid=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/productshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/productshow.php?cid=$2&id=$3&page=$4
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/case-([0-9]+)-([0-9]+)\.html$ $1/case.php?cid=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/caseshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/caseshow.php?cid=$2&id=$3&page=$4
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/join-([0-9]+)\.html$ $1/join.php?page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/joinshow-([0-9]+)\.html$ $1/joinshow.php?id=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/message-([0-9]+)\.html$ $1/message.php?page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)/contact-([0-9]+)-([0-9]+)\.html$ $1/contact.php?cid=$2&page=$3
RewriteRule ^about-([0-9]+)-([0-9]+)\.html$ about.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^news-([0-9]+)-([0-9]+)\.html$ news.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^newsshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ newsshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^product-([0-9]+)-([0-9]+)\.html$ product.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^productshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ productshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^case-([0-9]+)-([0-9]+)\.html$ case.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^caseshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ caseshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^join-([0-9]+)\.html$ join.php?page=$1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^joinshow-([0-9]+)\.html$ joinshow.php?id=$1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^message-([0-9]+)\.html$ message.php?page=$1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^contact-([0-9]+)-([0-9]+)\.html$ contact.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^soft-([0-9]+)-([0-9]+)\.html$ soft.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^softshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ softshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^goods-([0-9]+)-([0-9]+)-([0-9]+)\.html$ goods.php?cid=$1&tid=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^goodsshow-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ goodsshow.php?cid=$1&tid=$2&id=$3&page=$4
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^vote-([0-9]+)\.html$ vote.php?id=$1
Nginx下的规则如下:
rewrite ^/index.html$ /index.php last;
rewrite ^/city.html$ /city.php last;
rewrite ^/about-([0-9]+)-([0-9]+).html$ /about.php?cid=$1&page=$2 last;
rewrite ^/news-([0-9]+)-([0-9]+).html$ /news.php?cid=$1&page=$2 last;
rewrite ^/newsshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /newsshow.php?cid=$1&id=$2&page=$3 last;
rewrite ^/product-([0-9]+)-([0-9]+).html$ /product.php?cid=$1&page=$2 last;
rewrite ^/productshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /productshow.php?cid=$1&id=$2&page=$3 last;
rewrite ^/case-([0-9]+)-([0-9]+).html$ /case.php?cid=$1&page=$2 last;
rewrite ^/caseshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /caseshow.php?cid=$1&id=$2&page=$3 last;
rewrite ^/join-([0-9]+).html$ /join.php?page=$1 last;
rewrite ^/joinshow-([0-9]+).html$ /joinshow.php?id=$1 last;
rewrite ^/message-([0-9]+).html$ /message.php?page=$1 last;
rewrite ^/contact-([0-9]+)-([0-9]+).html$ /contact.php?cid=$1&page=$2 last;
rewrite ^/soft-([0-9]+)-([0-9]+).html$ /soft.php?cid=$1&page=$2 last;
rewrite ^/softshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /softshow.php?cid=$1&id=$2&page=$3 last;
rewrite ^/goods-([0-9]+)-([0-9]+)-([0-9]+).html$ /goods.php?cid=$1&tid=$2&page=$3 last;
rewrite ^/goodsshow-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+).html$ /goodsshow.php?cid=$1&tid=$2&id=$3&page=$4 last;
rewrite ^/vote-([0-9]+).html$ /vote.php?id=$1 last;
rewrite ^/(.+)/$ /index.php last;
rewrite ^/(.+)/index.html$ /index.php last;
rewrite ^/(.+)/index.php$ /index.php last;
rewrite ^/(.+)/about-([0-9]+)-([0-9]+).html$ /about.php?cid=$2&page=$3 last;rewrite ^/(.+)/news-([0-9]+)-([0-9]+).html$ /news.php?cid=$2&page=$3 last;
rewrite ^/(.+)/newsshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /newsshow.php?cid=$2&id=$3&page=$4 last;
rewrite ^/(.+)/product-([0-9]+)-([0-9]+).html$ /product.php?cid=$2&page=$3 last;
rewrite ^/(.+)/productshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /productshow.php?cid=$2&id=$3&page=$4 last;
rewrite ^/(.+)/case-([0-9]+)-([0-9]+).html$ /case.php?cid=$2&page=$3 last;
rewrite ^/(.+)/caseshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /caseshow.php?cid=$2&id=$3&page=$4 last;
rewrite ^/(.+)/join-([0-9]+).html$ /join.php?page=$2 last;
rewrite ^/(.+)/joinshow-([0-9]+).html$ /joinshow.php?id=$2 last;
rewrite ^/(.+)/message-([0-9]+).html$ /message.php?page=$2 last;
rewrite ^/(.+)/contact-([0-9]+)-([0-9]+).html$ /contact.php?cid=$2&page=$3 last;
如果直接在网上转换,可能不是很对。记录以备用。
Comment here is closed