nginx不支援pathinfo函數

來源:互聯網
上載者:User

標籤:style   blog   http   ar   io   color   使用   sp   strong   

server {        listen 80;        server_name www.domain.com domain.com;        error_page 404 /404.html;        error_page 500 502 503 504 /50x.html;        location ~ \.php {                root /data0/htdocs/www;                fastcgi_pass 127.0.0.1:9000;                #包含nginx伺服器傳遞給fastcgi程式的參數,php中通過$_SERVER[‘參數名‘]可擷取                include   fastcgi.conf;                #定義變數$fastcgi_script_name_new賦值為$fastcgi_script_name變數                set $path_info "";                set $fastcgi_script_name_new $fastcgi_script_name;                if ($fastcgi_script_name ~*  "^(.+\.php)(/.+)$") {                        set $fastcgi_script_name_new $1;                        set $path_info $2;                }                        #對fastcgi.conf中的SCRIPT_FILENAME和SCRIPT_NAME fastcgi參數進行重寫                        fastcgi_param   SCRIPT_FILENAME   $document_root$fastcgi_script_name_new;                        fastcgi_param   SCRIPT_NAME   $fastcgi_script_name_new;                        #定義一個新的nginx伺服器傳遞給fastcgi的參數PATH_INFO,thinkphp需要這個參數                        fastcgi_param   PATH_INFO $path_info;        }        location / {                root /data0/htdocs/www;                index  index.html index.htm;                if (!-e  $request_filename){                        rewrite ^(.*)$ /index.php$1 last;                }        }    }

tp支援PHPinfo

 

第二步:開啟thinkphp架構的設定檔convention.php,

修改URL_MODEL=>1,採用pathinfo模式,別設定成2啊,因為nginx重寫加上了index.php入口檔案了。

第三步:在瀏覽器輸入:www.domain.com,結果如下:

:)

歡迎使用 ThinkPHP!

[ 您現在訪問的是Home模組的Index控制器 ]

第四步:在瀏覽器中輸入URL時候,用rewrite形式的url,就是不要輸入入口檔案了,其它的不變和pathinfo模式一樣,例如:
http://www.domain.com/module/controler/action/參數1/值1/參數2/值2/

網址中不再需要輸入入口檔案index.php了,因為在剛才重寫時我們已經指定好了入口檔案index.php。

 

 

第二步:開啟thinkphp架構的設定檔convention.php,

修改URL_MODEL=>3,採用rewrite相容模式,並且修改
‘VAR_PATHINFO‘=> ‘s‘, 重寫時我們用的是s=""的形式.

第三步:在瀏覽器輸入:www.domain.com,結果如下:

:)

歡迎使用 ThinkPHP!

[ 您現在訪問的是Home模組的Index控制器 ]

第四步:在瀏覽器中輸入URL時候,還是用rewrite形式的url,就是不要輸入入口檔案了,其它的不變,例如:
http://www.domain.com/module/controler/action/參數1/值1/參數2/值2/

網址中不再需要輸入入口檔案index.php了,因為在剛才重寫時我們已經指定好了入口檔案index.php。

nginx不支援pathinfo函數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.