nginx偽靜態(tài)規(guī)則配置
nginx里使用偽靜態(tài)是直接在nginx.conf中寫規(guī)則的,并不需要像apache要開啟寫模塊(mod_rewrite)才能進行偽靜態(tài)。
nginx只需要打開nginx.conf配置文件,在server里面寫需要的規(guī)則即可。
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;? } #下面就是偽靜態(tài)了 location?/{? rewrite?^(.*)/equip(d+).html$?$1/index.php?m=content&c=index&a=lists&catid=$2?last;? }? access_log??access_log???off;? }
然后重啟nginx服務器偽靜態(tài)就生效了。
這種維護起來很是不方便我們可以把它寫在外部文件如bbs_nginx.conf中
在/home/www/bbs目錄下創(chuàng)建bbs_nginx.conf文件并寫入以下代碼:
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;
這樣網(wǎng)站根目錄中的bbs_nginx.conf偽靜態(tài)規(guī)則,即可實現(xiàn)單獨管理。
推薦教程:nginx教程
? 版權聲明
文章版權歸作者所有,未經(jīng)允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦