nginx伪静态规则配置
服务器配置文件:
server{
listen 80;
server_name www.abc.com;
root "D:/phpStudy/WWW/abc";
location / {
index index.php index.htm /public/index.html;
autoindex off;
include abc.conf;
#rewrite a.html /index.php/front/index/index last;
}
location ~ .php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
伪静态配置文件可以直接写在 location / {} 里面的,不推荐这样做,建议新增加个rewrite.conf写伪静态文件会好点,include 进来就行了,这样可以在rewrite.conf里面写n多配置
location / { index index.php index.htm /public/index.html;
autoindex off;
include rewrite.conf; #rewrite a.html /index.php/front/index/index last;
}
rewrite.conf (这个文件自己创建就行了,文件内容写规则)
#场景一的规则
#http://www.abc.com/index.php/front/index/indexrewrite a.html /index.php/front/index/index last;
#场景二的规则
#1.http://www.abc.com/index.php/front/index/parse/name/yangxignyi/age/18
#2.http://www.abc.com/index.php/front/index/parse?name=yangxignyi&age=18
#3.http://www.abc.com/parse-yangxingyi-18.htmlrewrite parse-(w+)-(d+).html /index.php/front/index/parse/name/$1/age/$2 last;
最后,重启nginx!
.pwarm{ text-indent:0px !important; padding: 5px !important; } .pwarm p,a,span{ text-indent:0px !important; word-break: break-all; }
版权声明:
作者:admin
链接:http://blog.mryxh.cn/1433.html
文章版权归作者所有,未经允许请勿转载。
THE END