nginx下配置laravel+rewrite重写
2024-08-25 01:29:40
server {
listen ;
server_name ha.d51v.cn;
#access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/demo/wechat_center/public;
index index.html index.htm index.php;
#error_page /.html;
#error_page /.html;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ /\.ht {
deny all;
}
#################以下是Nginx自定义配置的#######################
location / {
try_files $uri $uri/ /index.php?$query_string;
} if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$ permanent;
} # 去除index action
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$ permanent;
} # 根据laravel规则进行url重写
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$ last;
break;
}
#error_page /50x.html;
location = /50x.html {
root html;
}
}
最新文章
- AngularJs之七
- 【总结】详细说说@Html.ActionLink()的用法
- c#的学习
- java 7-nio异步I/O-将来式和回调式
- Spring的AOP与代理
- CentOS6.5 一键部署运行环境shell脚本
- css中>;,+,~的用法
- [Windows Server] 在 Windows Server 2012 上安裝 .NET Framework 3.5 - 摘自网络
- VB.NET版机房收费系统---七仙女之系统登录
- Spring Tool Suit 在Eclipse上的安装
- 修改 “嗨加游-Prefix.pch” 或者 “嗨加游-Info.plist ” 方法
- nginx配置ssl加密(单双向认证、部分https)
- 基于visual Studio2013解决面试题之0209最大堆排序
- ArcGIS API for JavaScript 4.2学习笔记[3] 官方第二章Mapping and Views概览与解释
- Java实现GB2312文件转UTF8文件
- [Usaco2015 Jan]Grass Cownoisseur Tarjan缩点+SPFA
- 关于本地化(localization)
- AXI
- CrawlSpider爬取拉钩
- 随机森林和GBDT