讓nginx支持thinkphp rewrite模式

Nginx環境
在Nginx低版本中,是不支持PATHINFO的,可是能夠經過在Nginx.conf中配置轉發規則實現:在nginx配置文件中添加

php

  1. location / { 
    nginx

  2.    if (!-e $request_filename) {
    服務器

  3.    rewrite ^(.*)$ /index.php?s=$1 last;
    dom

  4.    break;
    spa

  5.     }
    it

  6.  }io

其實內部是轉發到了ThinkPHP提供的兼容模式的URL,利用這種方式,能夠解決其餘不支持PATHINFO的WEB服務器環境。

若是你的ThinkPHP安裝在二級目錄,Nginx的僞靜態方法設置以下,其中youdomain是所在的目錄名稱。

  1. location /youdomain/ {
    ast

  2.         if (!-e $request_filename){
    配置

  3.             rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=$1 last;
    file

  4.         }

  5. }

相關文章
相關標籤/搜索