Rumah > Artikel > pembangunan bahagian belakang > 让nginx支持thinkmcf或thinkphp rewrite模式
<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>
<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>
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>
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了让nginx支持thinkmcf或thinkphp rewrite模式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。