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

伪静态是一种可以把文件后缀改成任何可能的一种方法,如果我想把php文件伪静态成html文件,这种相当简单的,下面我来介绍nginx 伪静态配置方法有需要了解的朋友可参考。

nginx里使用伪静态是直接在nginx.conf 中写规则的,并不需要像apache要开启写模块(mod_rewrite)才能进行伪静态。

nginx只需要打开nginx.conf配置文件,在server里面写需要的规则即可。

复制代码 代码如下:

server
{
listen       80;
server_name  bbs.0133.cn;
index index.html index.htm index.php;
root  /home/www/bbs;

error_page  404                                             /404.htm;       #配置404错误页面
location ~ .*.(php|php5)?$
{
#fastcgi_pass  unix:/tmp/php-cgi.sock;
fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}

#下面就是伪静态了

location /{
rewrite ^(.*)/equip(d+).html$ $1/index.php?m=content&c=index&a=lists&catid=$2 last;
}
access_log  access_log   off;
}

以上就是Nginx伪静态配置和常用Rewrite伪静态规则集锦的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 服务器