首页 > php教程 > php手册 > 正文

Laravel4 nginx rewrite配置

WBOY
发布: 2016-06-06 20:12:27
原创
862 人浏览过

采用php-fpm方式解释php,socket方式监听 nginx.conf示例: worker_processes??1; events?{ worker_connections??1024; } server?{ listen???????80; server_name??xxxx; #charset?utf-8; root???html/laravel/public; index??index.html?index.php; #?强制去

采用php-fpm方式解释php,socket方式监听

nginx.conf示例:
worker_processes??1;

events?{
worker_connections??1024;
}

server?{

listen???????80;
server_name??xxxx;

#charset?utf-8;
root???html/laravel/public;
index??index.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?{
deny??all;
}
}

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板