Home > php教程 > php手册 > CodeIgniter在nginx下的Rewrite规则

CodeIgniter在nginx下的Rewrite规则

WBOY
Release: 2016-06-06 20:13:13
Original
1364 people have browsed it

虽然说apache配置简单粗暴,比如CodeIgniter在apache下连配置都不用就可以直接上了,但是小内存的主机下,nginx的轻巧却足以掩盖它难以配置的缺点。如果你正在nginx上使用CodeIgniter,发现除了首页,其他页面全部都404了,那肯定是Rewrite规则错了。网上搜

虽然说apache配置简单粗暴,比如CodeIgniter在apache下连配置都不用就可以直接上了,但是小内存的主机下,nginx的轻巧却足以掩盖它难以配置的缺点。如果你正在nginx上使用CodeIgniter,发现除了首页,其他页面全部都404了,那肯定是Rewrite规则错了。网上搜到的很多规则貌似都是不能用的。

这里分享一段CodeIgniter在nginx下的可用Rewrite规则(并没有去掉index.php)。

location / {
if (-f $request_filename/index.html){
                rewrite (.*) $1/index.html break;
        }
if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
if (!-f $request_filename){
                rewrite (.*) /index.php;
        }
}
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template