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文件并寫入以下代碼:
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教程
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦