nginx配置ThinkPHP Rewrite

來源:互聯網
上載者:User

標籤:style   blog   color   io   ar   檔案   sp   div   on   

server {     listen       80;     server_name  www.funsion.com;     root /www/web/funsion;     index  index.php;     # 禁止訪問應用目錄中的php檔案     location ~* ^/application/.+\.php$ {        #此目錄下的.html要允許訪問,因為靜態html緩衝也是在這個目錄下產生          return  403;     }     location ~*  ^/application/Tpl/.+\.html$ {          return  403;         # 禁止訪問模板目錄下的html檔案     }     # 禁止訪問ThinkPHP目錄中的檔案     location ~* ^/ThinkPHP/.+\.(php|tpl|html)$ {          return  403;                        }     location / {         # ThinkPHP Rewrite, 除以上指定的靜態資源外,其它的請求才有必要進行判斷         if (!-e $request_filename){             rewrite ^/(.*)$ /index.php/$1 last;         }     }          location ~ \.php($|/){         #配置PHP支援PATH_INFO進行URL重寫         set $script     $uri;         set $path_info  "";         if ($uri ~ "^(.+?\.php)(/.+)$") {             set $script     $1;             set $path_info  $2;         }         fastcgi_pass   127.0.0.1:9000;         fastcgi_index  index.php;         include fcgi.conf;         fastcgi_param  SCRIPT_FILENAME        $document_root$script;         fastcgi_param  SCRIPT_NAME            $script;         fastcgi_param  PATH_INFO              $path_info;     }          location ~* .+\.(gif|jpg|jpeg|png|bmp|swf) {           expires      7d;     }         location ~* .+\.(js|css) {           # 緩衝一年,檔案每次修改後需要在URL中加入時間戳記,否則會讀取緩衝           expires      1y;     } }

 

nginx配置ThinkPHP Rewrite

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.