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文件的根目录
总结
以上所述是小编给大家介绍的Laravel的Nginx重写规则实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!
相关推荐
-
Nginx中运行PHP框架Laravel的配置文件分享
配置文件改成这样 server { listen 80; server_name sub.domain.com; set $root_path '/srv/www/default'; root $root_path; index index.php index.html index.htm; try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location ~ \.
-
Laravel 5.5官方推荐的Nginx配置学习教程
前言 本文主要给大家介绍了关于Laravel 5.5官方推荐的Nginx配置的想内容,分享出来供大家参考学习,下面话不多说,来一起看看详细的介绍把. Laravel 5.5 版本官方放出了 Nginx 服务器的配置,中文文档:服务器配置 Nginx server { listen 80; server_name example.com; root /example.com/public; add_header X-Frame-Options "SAMEORIGIN"; add_head
-
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 ^
-
在swoole中制作一款仿制laravel的框架的实例代码
首先需要确定一下思路:我希望基于swoole的扩展开发的代码在run起来的时候,在接收到ws或是tcp等消息时,自动路由到某个类上,同时类可以实现加载类的依赖注入功能.目前市面上占据主流的一款框架Laravel,其中有一个依赖注入的功能非常的便捷.一般在通常的框架中拉取Class是这样做的: class a { public $bClassInstance; public function __construct(Class b) { $classInstance = new b(); } pu
-
Nginx的完整配置详解及实例代码
Nginx的完整配置详解 最近公司新项目,由于自己是小白,跟着项目经理对Nginx进行配置,在网上找到一篇相关资料,觉得不错,并可以完成配置,这里记录下, 实例代码: #运行用户 user nobody; #启动进程,通常设置成和cpu的数量相等 worker_processes 1; #全局错误日志及PID文件 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;
-
laravel框架的缓存操作代码实例
laravel为不同的缓存系统提供了统一的API.缓存配置位于config/cache.php.Laravel目前支持主流的缓存后端有Memcached和Redis等. 主要方法: cache::put() cache::get() cache::add() cache::pull() cache::forever() cache::forget() cahce::has() 系统默认是使用文件缓存,其缓存文件储存的位置位于storage/framework/cahce/date 设置缓存 语法
-
laravel下trait的使用代码实例详解
前言 今天在整理laravel的练习项目时,发现自己的代码结构中有很多重复的代码.于是搜索了一下laravel框架的代码复用机制.知道了Trait的存在,于是学习使用了一下. 关于Trait的理解 Trait是PHP5.4引入的新概念,定义方式和class的定义方式类似.但是并不具备class的完整性.Trait看上去更像是一个class的一部分.它使不相关的两个class能够具有类似的行为. Trait的简单使用 新建一个Trait 本人由于数据库操作上使用了eloquent模型,在多表查询时
-
vue webpack多页面构建的实例代码第1/3页
项目示例地址: https://github.com/ccyinghua/webpack-multipage 项目运行: 下载项目之后 # 下载依赖 npm install # 运行 npm run dev http://localhost:3000/login.html http://localhost:3000/index.html 一.开发环境 node v6.11.0 二.安装vue-cli脚手架 npm install vue-cli@2.8.2 -g 三.初始化项目 vue init
-
微信小程序实现即时通信聊天功能的实例代码
项目背景:小程序中实现实时聊天功能 一.服务器域名配置 配置流程 配置参考URL:https://developers.weixin.qq.com/miniprogram/dev/api/api-network.html 二.nginx中配置反向代理加密websocket(wss) upstream websocket{ hash $remote_addr consistent; server 127.0.0.1:9090 weight=5 max_fails=3 fail_timeout=30
-
php获取用户真实IP和防刷机制的实例代码
一. 如何获取用户IP地址 public static function getClientIp() { if (getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CLIENT_IP'); } if (getenv('HTTP_X_REAL_IP')) { $ip = getenv('HTTP_X_REAL_IP'); } elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FO
-
PHP 获取客户端 IP 地址的方法实例代码
先来了解一个变量的含义: $_SERVER['REMOTE_ADDR']:浏览当前页面的用户计算机的ip地址 $_SERVER['HTTP_CLIENT_IP']:客户端的ip $_SERVER['HTTP_X_FORWARDED_FOR']:浏览当前页面的用户计算机的网关 $_SERVER['HTTP_X_REAL_IP']:nginx 代理模式下,获取客户端真实IP /** * 获取客户端IP地址 */ function real_ip() { $ip = $_SERVER['REMOTE_
-
SpringBoot 整合Jest实例代码讲解
[1]添加Elasticsearch-starter pom文件添加starter如下: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency> SpringBoot默认支持两种技术和Elasticsearch进行交互:Sp
随机推荐
- 惊现学习CSS应该注意的方法
- jquery 的 $("#id").html() 无内容的解决方法
- 用Js实现的动态增加表格示例自己写的
- windows7 安装iis7.0图文教程(不需要单独的安装包)
- Kotlin 基础教程之泛型
- JavaWeb中上传和下载文件实例代码
- 基于PHP实现栈数据结构和括号匹配算法示例
- Python编程中的反模式实例分析
- C# SQLite事务操作方法分析
- Android实现点击AlertDialog上按钮时不关闭对话框的方法
- Android中极简的js与java的交互库(SimpleJavaJsBridge)
- Bootstrap Table使用方法详解
- Javascript图像处理思路及实现代码
- Javascript 去除数组的重复元素
- JavaScript作用域链示例分享
- 关于硬盘容量的说明
- eclipse报错 eclipse启动报错解决方法
- Android 使用 RxJava2 实现倒计时功能的示例代码
- python实现快速排序的示例(二分法思想)
- 对vue v-if v-else-if v-else 的简单使用详解