一起源码网

  • www.171739.xyz
  • 全球最大的互联网技术和资源下载平台
搜索
猜你喜欢
查看: 8469|回复: 1
打印 上一主题 下一主题

Laravel中关于Nginx重写规则的示例

[复制链接]

0

主题

0

帖子

1万

积分

钻石会员

Rank: 8Rank: 8

积分
17424
QQ
跳转到指定楼层
楼主
发表于 2020-5-6 07:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
这篇文章主要介绍了Laravel的Nginx重写规则实例代码,需要的朋友可以参考下

laravel基本重写规则


location / {
    index index.html index.htm index.php;
    try_files $uri $uri/ /index.php?$query_string ; 
}

去除末尾的斜杠,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;
}

错误信息跳转页面必须在location ~ .php(.*)${}里面加入条:fastcgi_intercept_errors on开启错误检测信息

#nginx错误信息跳转自定义页面50x.html自己随便定义


error_page 404 500 502 503 504 error.html;
location = error.html {
    root  html;
}

root是error文件的根目录

总结

分享到:  QQ好友和群QQ好友和群
收藏收藏
回复

使用道具 举报

0

主题

13

帖子

131

积分

注册会员

Rank: 2

积分
131
沙发
发表于 2022-10-4 05:58 | 只看该作者
怎么用网页代码下音频
回复

使用道具 举报

一起源码让程序更轻更快

www.171739.xyz

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表