服务器配置文件:
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!
版权声明:
此文为本站源创文章[或由本站编辑从网络整理改编],
转载请备注出处:
[狂码一生]
https://www.sindsun.com/articles/23/73
[若此文确切存在侵权,请联系本站管理员进行删除!]
--THE END--