Home > Backend Development > PHP Tutorial > Let nginx support thinkmcf or thinkphp rewrite mode

Let nginx support thinkmcf or thinkphp rewrite mode

WBOY
Release: 2016-07-30 13:30:54
Original
1308 people have browsed it
  1. 如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中subdir是所在的目录名称。
<code>location /subdir/ {
        <span>if</span> (!-e <span>$request_filename</span>){
            rewrite ^<span>/subdir/</span>(.*)<span>$ </span>/subdir/index.php?s=<span>$1</span> last;
        }
}</code>
Copy after login
  1. 如果你的thinkcmf安装在二级目录,Nginx的伪静态方法设置如下,其中subdir是所在的目录名称。
<code>location ~ <span>/subdir/</span>\w+ {
            <span>if</span> (!-e <span>$request_filename</span>)
            {
                rewrite ^<span>/(\w+)/</span>(.*)<span>$ </span>/<span>$1</span>/index.php/<span>$2</span>;
            }
        }</code>
Copy after login

ps: 在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:在nginx配置文件中添加

<code>location / { 
   <span>if</span> (!-e <span>$request_filename</span>) {
   rewrite ^(.<span>*)</span>$ /<span>index</span>.php?<span>s</span>=<span>$1</span><span>last</span>;
   <span>break</span>;
    }
 }</code>
Copy after login

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了让nginx支持thinkmcf或thinkphp rewrite模式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template