
nginx伪静态规则配置
nginx里使用伪静态是直接在nginx.conf中写规则的,并不需要像apache要开启写模块(mod_rewrite)才能进行伪静态。
nginx只需要打开nginx.conf配置文件,在server里面写需要的规则即可。
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服务器伪静态就生效了。
这种维护起来很是不方便我们可以把它写在外部文件如bbs_nginx.conf中
在/home/www/bbs目录下创建bbs_nginx.conf文件并写入以下代码:
[PHP房产程序|BBWPS]功能介绍 1、5种信息类别发布:出租、求租、出售、求购、楼盘信息,支持会员发布信息审核; 2、灵活的信息参数设置; 3、充足的信息字段; 4、简单易用的发布/编辑功能,支持配图上传; 5、灵活的信息管理功能; 6、信息输出伪静态,方便搜索引擎抓取数据; 7、支持RSS输出; 8、内置数据高速缓冲技术,可灵活设置缓冲功能是否启动及过期时间; 9、支持 Google 地图
location /{
rewrite ^(.*)/equip(d+).html$ $1/index.php?m=content&c=index&a=lists&catid=$2 last;
}然后在上面的nginx.conf代码后面加上如下代码:
include /home/www/bbs/bbs_nginx.conf;
这样网站根目录中的bbs_nginx.conf伪静态规则,即可实现单独管理。
推荐教程:nginx教程









