2019-11-29 热度:4874,编辑:
1) 配置说明:支持Pathinfo,让您的URL更友好,原:http://www.xxx.com/index.php?c=c&m=m&ac=a,可以优化为:http://www.xxx.com/m/c/a
2) 具体配置(复制粘贴即可):
Server {
…
location ~ .php($|/) {
#nginx support path_info
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+.php)(/.+)") {
set $script $1;
set $path_info $2;
}
#Pass the PHPscripts to FastCGI server listening on 127.0.0.1:9000
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param SCRIPT_NAME $script;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
…
}配置说明:支持短路径配置,原链接:http://www.xxx.com/index.php/aboutus,可以优化为:http://www.xxx.com/aboutus
具体配置:
Server {
…
location / {
index index.php index.html index.htm;
rewrite ^/$ /index.php last;
rewrite ^/(?!index.php|.*.txt|.*.html|.*.htm|.*.swf|static|runtime|vendor)(.*)$ /index.php/$1 last;
}
…
}注意:配置修改完后,请重启您的WEB服务器!URL的优化可让您的网站更易被搜索引擎收录,同时对用户也越加友好,强烈建议您使用。
