最近一直在捯饬蚂蚁分类这套程序,服务器环境:nginx1.12+php5.2+mysql5.5+zend3.3,在后台开启伪静态之后全部404,排查发下伪静态规则没有配置,翻遍搜索引擎都是IIS Web Server或者Apache Web Server,关于nginx的顶多就搜索到个多城市版本,使用后还是有部分不合适,想淘宝找人写,嗯,报价30元,挺实惠,想想还是算了,自己不就喜欢自己折腾么,花钱了就没那个意思了。用网上很多Apache转nginx的工具转换了官方的规则直接使用还是不合适,后来对照网上多城市的规则做了修改,总算完美了,下面分享给正在使用5.8单城市版本的朋友!
rewrite ^/space/(.+)/$ /space.php?user=$1;
rewrite ^/store-([0-9]+)/$ /store.php?uid=$1;
rewrite ^/store-([0-9]+)/([^/]+).html$ /store.php?uid=$1&Uid=$2;
if (!-d $request_filename){
set $rule_3 1$rule_3;
}
if ($rule_3 = "1"){
rewrite ^/(?!store|space)(.+)/$ /category.php?Catid=$1;
}
rewrite ^/([^/]+)/([0-9]+).html$ /information.php?id=$2;
rewrite ^/news.html$ /news.php;
rewrite ^/news-id-([0-9]+).html$ /news.php?id=$1;
rewrite ^/news-catid-([0-9]+).html$ /news.php?catid=$1;
rewrite ^/news-catid-([0-9]+)-page-([0-9]+).html$ /news.php?catid=$1&page=$2;
rewrite ^/goods.html$ /goods.php;
rewrite ^/goods-id-([0-9]+).html$ /goods.php?id=$1;
rewrite ^/goods-([^/]+).html$ /goods.php?Catid=$1;
rewrite ^/corporation.html$ /corporation.php;
rewrite ^/corporation-([^/]+).html$ /corporation.php?Catid=$1;
rewrite ^/aboutus.html$ /about.php?part=aboutus;
rewrite ^/sitemap.html$ /about.php?part=sitemap;
rewrite ^/aboutus-id-([0-9]+).html$ /about.php?part=aboutus&id=$1;
rewrite ^/announce.html$ /about.php?part=announce&id=$1;
rewrite ^/faq.html$ /about.php?part=faq;
rewrite ^/faq-id-([0-9]+).html$ /about.php?part=faq&id=$1;
rewrite ^/friendlink.html$ /about.php?part=friendlink;
程序伪静态设置截图如下:
版权声明
声明:本站所有主题/文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系本站删除,谢谢合作!
发表评论