您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Laravel4 nginx rewrite配置

2025/8/1 0:48:48发布22次查看
采用php-fpm方式解释php,socket方式监听 nginx.conf示例: worker_processes1; events?{ worker_connections1024; } server?{ listen?80; server_namexxxx; #charset?utf-8; root?html/laravel/public; indexindex.html?index.php; #?强制去
采用php-fpm方式解释php,socket方式监听
nginx.conf示例:
worker_processes1;
events?{
worker_connections1024;
}
server?{
listen?80;
server_namexxxx;
#charset?utf-8;
root?html/laravel/public;
indexindex.html?index.php;
#?强制去除www
if?($host?~*?^www\.(.*))
{
set?$host_without_www?$1;
rewrite?^/(.*)$?$scheme://$host_without_www/$1?permanent;
}
#?处理静态文件
location?~*?\.(jpg|jpeg|gif|css|png|js|ico|html)$?{
access_log?off;
expires?max;
}
#?去除末尾的斜杠,seo更加友好
if?(!-d?$request_filename)
{
rewrite?^/(.+)/$?/$1?permanent;
}
#?去除index?action
if?($request_uri?~*?index/?$)
{
rewrite?^/(.*)/index/?$?/$1?permanent;
}
#?根据laravel规则进行url重写
if?(!-e?$request_filename)
{
rewrite?^/(.*)$?/index.php?/$1?last;
break;
}
error_page?500?502?503?504/50x.html;
location?=?/50x.html?{
root?html;
}
location?~?\.php$?{
include?fastcgi.conf;
fastcgi_pass?unix:/var/run/php5-fpm.sock;
fastcgi_index?index.php;
include?fastcgi_params;
}
location?~?/\.ht?{
denyall;
}
}
原文地址:laravel4 nginx rewrite配置, 感谢原作者分享。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product