1.在nginx的配置里面,進行重定向
vi /etc/nginx/conf.d/default.conf
2.進入編輯
location /thinkphp/public {
if (!-e $request_filename){ rewrite ^/thinkphp/public/(.*)$ /thinkphp/public/index.php?s=$1 last; } }
這樣訪問ip/thinkphp/public/index/index/index,會報404,但是會轉去請求
/thinkphp/public/index.php/index/index/index再返回,就能顯示正確的數據了
/thinkphp/public/可以根據你自己寫的目錄進行修改配置,想寫到里面就寫到哪里,並不受約束,在nginx的配置里面替換掉就可以了
就在這個thinkphp框架里面,寫對數據庫的操作,和請求的url
3.重啟服務器
service nginx restart