🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
服务器配置文件 ``` server{ listen 80; server_name www.test.com; root "D:/phpStudy/WWW/test"; 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/index #重写成http://www.abc.com/a.html rewrite a.html /index.php/front/index/index last; #场景二的规则 #把下面带参数的两个url #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.html rewrite parse-(\w+)-(\d+).html /index.php/front/index/parse/name/$1/age/$2 last; ```