7.nginx伪静态规则

网上收集的一些常用的,要用的时候就仿照一下,或直接拿来用。

WordPress伪静态规则

location / { 
index index.html index.php; 
if (-f $request_filename/index.html){ 
rewrite (.*) $1/index.html break; 

if (-f $request_filename/index.php){ 
rewrite (.*) $1/index.php; 

if (!-f $request_filename){ 
rewrite (.*) /index.php; 

}

PHPCMS伪静态规则

location / { 
###以下为PHPCMS 伪静态化rewrite规则 
rewrite ^(.*)show-([0-9]+)-([0-9]+)\.html$ $1/show.php?itemid=$2&page=$3; 
rewrite ^(.*)list-([0-9]+)-([0-9]+)\.html$ $1/list.php?catid=$2&page=$3; 
rewrite ^(.*)show-([0-9]+)\.html$ $1/show.php?specialid=$2; 
####以下为PHPWind 伪静态化rewrite规则 
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last; 
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last; 
}

ECSHOP伪静态规则 

if (!-e $request_filename) 

rewrite "^/index\.html" /index.php last; 
rewrite "^/category$" /index.php last; 
rewrite "^/feed-c([0-9]+)\.xml$” /feed.php?cat=$1 last; 
rewrite “^/feed-b

([0-9]+)\.xml$” /feed.php?brand=$1 last; 
rewrite “^/feed\.xml$” /feed.php last; 
rewrite “^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last; 
rewrite “^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$” /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last; 
rewrite “^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last; 
rewrite “^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$” /category.php?id=$1&brand=$2&page=$3 last; 
rewrite “^/category-([0-9]+)-b([0-9]+)(.*)\.html$” /category.php?id=$1&brand=$2 last; 
rewrite “^/category-([0-9]+)(.*)\.html$” /category.php?id=$1 last; 
rewrite “^/goods-([0-9]+)(.*)\.html” /goods.php?id=$1 last; 
rewrite “^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last; 
rewrite “^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$” /article_cat.php?id=$1&page=$2 last; 
rewrite “^/article_cat-([0-9]+)(.*)\.html$” /article_cat.php?id=$1 last; 
rewrite “^/article-([0-9]+)(.*)\.html$” /article.php?id=$1 last; 
rewrite “^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html” /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last; 
rewrite “^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html” /brand.php?id=$1&cat=$2&page=$3 last; 
rewrite “^/brand-([0-9]+)-c([0-9]+)(.*)\.html” /brand.php?id=$1&cat=$2 last; 
rewrite “^/brand-([0-9]+)(.*)\.html” /brand.php?id=$1 last; 
rewrite “^/tag-(.*)\.html” /search.php?keywords=$1 last; 
rewrite “^/snatch-([0-9]+)\.html$” /snatch.php?id=$1 last; 
rewrite “^/group_buy-([0-9]+)\.html$” /group_buy.php?act=view&id=$1 last; 
rewrite “^/auction-([0-9]+)\.html$” /auction.php?act=view&id=$1 last; 
rewrite “^/exchange-id([0-9]+)(.*)\.html$” /exchange.php?id=$1&act=view last; 
rewrite “^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last; 
rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$” /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last; 
rewrite “^/exchange-([0-9]+)-([0-9]+)(.*)\.html$” /exchange.php?cat_id=$1&page=$2 last; 
rewrite “^/exchange-([0-9]+)(.*)\.html$” /exchange.php?cat_id=$1 last; 
}

Discuz 7伪静态规则 

rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index

.php?$1 last; 
rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last; 
rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page\%3D$3&page=$2 last; 
rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last; 
rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;

时间: 2024-07-29 07:12:02

7.nginx伪静态规则的相关文章

Nginx伪静态规则

nginx伪静态规则 要将http://lovo.com/index.php?t=3用伪静态规则改写成http://lovo.com/t3.html,即可在nginx的conf/nginx.conf里面添加即可. 在location / {}里添加,如: location / {            root   /var/www/html;            index  index.php index.html index.htm;            rewrite ^(.*)/t

Laravel nginx 伪静态规则

最近在调研各种的PHP框架(CI, Cake, ThinkPHP, Laravel, Yii)感觉Laravel看上去很美,深入了解了下.开发机使用的是Apache,Stage上跑的nginx,部署后碰到所有的重定向都报404错误的情况.搞了半天,最后把下面这段代码加到nginx的配置中终于搞定了. try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } 配置文件看上去是这

建站初学者必知的wordpress在Nginx/Apache/IIS中的伪静态规则

在搭建好wordpress博客以后,我都是先让大家配置好文章的url格式为/%postname%.html这样的自定义结构的.比如是阿里云的虚拟主机这样配置以后,文章页面还是可以打开的,但是有的服务器或者是虚拟主机就打不开了,这就需要大家配置好伪静态的规则. 现在,我就把怎么配置wordpress的伪静态规则发出来给大家一起来学习. wordpress的Nginx/Apache/IIS伪静态规则 NGINX伪静态规则 Nginx环境是Linux服务器里面常见的网站配置环境,完整网站环境是Linu

Nginx伪静态配置和常用Rewrite伪静态规则

伪静态是一种可以把文件后缀改成任何可能的一种方法,如果我想把php文件伪静态成html文件,这种相当简单的,下面来介绍nginx 伪静态配置方法有需要了解的朋友可参考. nginx里使用伪静态是直接在nginx.conf 中写规则的,并不需要像apache要开启写模块(mod_rewrite)才能进行伪静态. nginx只需要打开nginx.conf配置文件,在server里面写需要的规则即可. 代码如下: server { listen       80; server_name  haha.

nginx 伪静态 rewrite

前一段时间领导让我用nginx做个伪静态,实现效果如下: 原URL http://www.domain.com/abc/def.jsp?x=1&y=2&z=3 转换为http://www.domain.com/abc/def-1-2-3.html,当我访问原URL时,浏览器的地址栏里显示的是转换后的URl,但内容还是原来动态页面的内容. 开始我是这么写的 rewrite ^/abc/def-(.*)\-(.*)\-(.*)\.html$ /abc/def.jsp?x=$1&y=$2

nginx伪静态配置教程总结

在nginx中配置伪静态,也就是常说的url重写功能,只需在nginx.conf配置文件中写入重写规则即可. 当然,这个规则是需要熟悉正则表达式,只掌握nginx自身的正则匹配模式即可,对正则不了解的朋友,建议补一下这方面的知识. 下面,收集了几篇关于nginx rewrite重写的教程文章,感兴趣的朋友可以看看. nginx伪静态.url rewrite重写教程: nginx配置301重定向及rewrite重写规则说明 nginx rewrite重写规则语句配置示例 nginx中url重写规则

Nginx Rewrite规则记录

Rewrite 是一种服务器的重写脉冲技术,它可以使得服务器可以支持 URL 重写,是一种最新流行的服务器技术.它还可以实现限制特定IP访问网站的功能.很多情况下,某个 IP 的访问很容易造成 CPU 100% (比如 某些搜索引擎的固定抓取,别人大量的采集站点),这个时候我们就要利用一些有效的手段封掉对方的 IP,让他无法消耗服务器的资源,封 IP 的方法有很多种,如果你的 Web(Nginx|Apache|other) 服务器安装了 Rewrite 模块的话,也可以试试利用 Rewrite

nginx重定向规则详细介绍

为何要使用301重定向 在网站建设中需要网页重定向的情况很多:如网页目录结构变动,网页重命名.网页的扩展名改变.网站域名改变等.如果不做重定向,用户的收藏和搜索引擎数据库中的旧地址只能让访客得到一个404错误信息页面,访问流量白白丧失.不仅如此,之前该页面的一切积累(比如PR值)就都白费了. 301重定向不仅能使页面实现自动跳转,对于搜索引擎来说,也可能可以传递PR值. nginx重定向规则详细介绍 http://www.jefflei.com/post/1015.html rewrite命令n

CI框架 CodeIgniter 伪静态 htaccess设置和Nginx伪静态方法

众所周知,LAMP代表Linux下Apache.MySQL.PHP这种网站服务器架构:而LNMP指的是Linux下Nginx.MySQL.PHP这种网站服务器架构.LNMP一键安装包可以从网上下载使用. Nginx(发音同 engine x)由 Igor Sysoev 用C语言为俄罗斯访问量第二的搜索引擎 Rambler.ru 站点开发,是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3/SMTP)代理服务器,其将源代码以类BSD许可证的形式发布,并在一个BSD-like