本文摘自PHP中文网,作者angryTom,侵删。

nginx伪静态规则配置
nginx里使用伪静态是直接在nginx.conf中写规则的,并不需要像apache要开启写模块(mod_rewrite)才能进行伪静态。
nginx只需要打开nginx.conf配置文件,在server里面写需要的规则即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | server
{
listen 80;
server_name www.php.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服务器伪静态就生效了。
阅读剩余部分
相关阅读 >>
负载均衡之nginx详解
编译安装nginx却requires the pcre library
nginx反向代理和正向代理的区别是什么
怎样平稳安全地升级nginx版本
重启nginx有哪几种方法
探讨openresty和nginx的共享内存区使用物理内存资源(或 ram)?
使用nginx和nginx-rtmp-module搭建流媒体服务器
比较讲解http中499状态码和nginx下499错误
nginx怎么解决跨域?
windows下nginx的启动与停止命令介绍
更多相关阅读请进入《nginx》频道 >>
转载请注明出处:木庄网络博客 » nginx伪静态规则配置