標籤: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函數