URL rewrite method
server { listen 8080; server_name www.xxx.com; root /Users/lch/work/www/ci; access_log /usr/local/var/log/access.log; error_log /usr/local/ var/log/error.log; location ~ ^/(img|images|script|js|css|upload)/ { root /Users/lch/work/www/ci; break; } location ~ { if (!-e $request_filename) { # for /admin rewrite ^/(admin)$ /index.php?c=welcome&m=index&d=$1 break; # for /admin/index rewrite ^/(admin)/([a-zA-Z_] +)$ /index.php?c=$2&m=index&d=$1 break; # for /admin/account/login rewrite ^/(admin+)/([a-zA-Z_]+)/([a-zA- Z_]+)$ /index.php?c=$2&m=$3&d=$1 break; ## for general URL rewrite ^/([a-zA-Z_]+)/([a-zA-Z_]+) /?(.*)$ /index.php?c=$1&m=$2 last; } root /Users/lch/work/www/ci; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$ fastcgi_script_name; include fastcgi_params; } }
Explain the above configuration, because I created a new folder admin in application/controllers/ to specifically store background-related controllers, so there is one more layer than the ordinary path (corresponding to &d =admin) this parameter. Here you can see the shortcomings of the rewrite method. When a situation like admin occurs, the corresponding rewrite rules must be added.
PATH_INFO method
server { listen 8080; server_name www.xxx.com; root /Users/lch/work/kidulty/snap_www; access_log /usr/local/var/log/snap_access.log; error_log /usr/local/ var/log/snap_error.log; location ~ ^/(img|images|script|js|css|upload)/ { root /Users/lch/work/kidulty/snap_www; break; } if (!-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; } location ~ { set $path_info ""; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?.php)(/.+ )$") { set $real_script_name $1; set $path_info $2; } root /Users/lch/work/kidulty/snap_www; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $ real_script_name; fastcgi_param PATH_INFO $path_info; include fastcgi_params; } }
Note:
If the URL in the project is similar to http://www.xxx.com/index.php/user/profile, there is no need to rewrite the following:
if (!-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; }
The above is the content of Nginx configuration CodeIgniter project (2). For more related content, please pay attention to the PHP Chinese website (www .php.cn)!

CodeIgniter中间件:加速应用程序的响应速度和页面渲染概述:随着网络应用程序的复杂性和交互性不断增长,开发人员需要使用更加高效和可扩展的解决方案来提高应用程序的性能和响应速度。CodeIgniter(CI)是一种基于PHP的轻量级框架,提供了许多有用的功能,其中之一就是中间件。中间件是在请求到达控制器之前或之后执行的一系列任务。这篇文章将介绍如何使用

Nginx错误页面配置,美化网站故障提示在网站运营过程中,难免会遇到服务器错误或者其他故障,这些问题会导致用户无法正常访问网站。为了提升用户体验和网站形象,我们可以对Nginx进行错误页面配置,美化网站故障提示。本文将介绍如何通过Nginx的错误页面配置功能,自定义错误页面,并提供代码示例作为参考。一、修改Nginx配置文件首先,我们需要打开Nginx的配置

在CodeIgniter框架中使用数据库查询构建器(QueryBuilder)的方法引言:CodeIgniter是一个轻量级的PHP框架,它提供了许多功能强大的工具和库,方便开发人员进行Web应用程序开发。其中一个令人印象深刻的功能是数据库查询构建器(QueryBuilder),它提供了一种简洁而强大的方法来构建和执行数据库查询语句。本文将介绍如何在Co

随着Web应用程序的不断发展,更加快速和高效地开发应用程序变得非常重要。并且,随着RESTfulAPI在Web应用程序中的广泛应用,对于开发人员来说,必须理解如何创建和实现RESTfulAPI。在本文中,我们将讨论如何使用CodeIgniter框架实现MVC模式和RESTfulAPI。MVC模式简介MVC(Model-Vie

CodeIgniter是一个轻量级的PHP框架,采用MVC架构,支持快速开发和简化常见任务。CodeIgniter5是该框架的最新版本,提供了许多新的特性和改进。本文将介绍如何使用CodeIgniter5框架来构建一个简单的Web应用程序。步骤1:安装CodeIgniter5下载和安装CodeIgniter5非常简单,只需要遵循以下步骤:下载最新版本

如何实现Nginx的跨域资源共享(CORS)配置,需要具体代码示例随着前后端分离开发的流行,跨域资源共享(CORS)问题成为了一个常见的挑战。在Web开发中,由于浏览器的同源策略限制,客户端JavaScript代码只能请求与其所在页面具有相同域名、协议和端口的资源。然而,在实际开发中,我们常常需要从不同域名、或者是不同子域名下请求资源。这时候,就需要使用CO

现今互联网时代,一款深受用户喜爱的网站必须具备简洁明了的前端界面和功能强大的后台管理系统,而PHP框架CodeIgniter则是一款能够让开发者快速搭建后台管理系统的优秀框架。CodeIgniter拥有轻量级、高效率、易扩展等特点,本文将针对初学者,详细说明如何通过该框架快速搭建一个后台管理系统。一、安装配置安装PHPCodeIgniter是一个基于PHP的

随着移动互联网的发展,即时通信变得越来越重要,越来越普及。对于很多企业而言,实时聊天更像是一种通信服务,提供便捷的沟通方式,可以快速有效地解决业务方面的问题。基于此,本文将介绍如何使用PHP框架CodeIgniter开发一个实时聊天应用。了解CodeIgniter框架CodeIgniter是一个轻量级的PHP框架,提供了一系列的简便的工具和库,帮助开发者快速


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
