Laravel4 nginx rewrite配置
采用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;
}
}
原文地址:Laravel4 nginx rewrite配置, 感谢原作者分享。
上一篇: 怎么查看电脑系统是32位还是64位?
下一篇: Linux如何创建用户
推荐阅读
-
Linux VPS上配置Nginx反向代理的方法
-
Laravel 5.5官方推荐的Nginx配置学习教程
-
在CentOS上配置Nginx+Gunicorn+Python+Flask环境的教程
-
Nginx DNS resolver配置实例
-
分析nginx日志并屏蔽采集者ip(nginx屏蔽ip配置实例)
-
Nginx Rewrite规则与使用介绍和技巧实例
-
nginx跨域解决方案(教你nginx如何配置跨域)
-
nginx配置反向代理和负载均衡(nginx功能介绍和使用)
-
在阿里云服务器上配置CentOS+Nginx+Python+Flask环境
-
nginx配置反向代理和负载均衡(nginx功能介绍和使用)