歡迎您光臨本站 註冊首頁

請教一個nginx rewrite或默認文檔的問題

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

請教一個nginx rewrite或默認文檔的問題

我配置了一段nginx的虛擬主機,想要實現當訪問根目錄下的文件時,去調用/control/web/下的文件,而如果根目錄下不寫任何東西(即只訪問域名),則取調用/control/web/下的默認文件,即index.html、index.htm、index.php,如下是配置信息,當訪問域名網址時,提示"500 Internal Server Error",但是/control/web/下確實有index.html文件。
配置如下:
server
{
       listen       80;
       server_name www.abcd.com;
       index index.html index.htm index.php;
       root /www/;

       rewrite ^/(.*) /control/web/$1;

       location ~ .*\.php$ {
       fastcgi_pass   127.0.0.1:9000;
       fastcgi_index  index.php;
       fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include  fastcgi_params;
       }
}

查看錯誤日誌:
2009/07/19 23:32:44 17053#0: *95 rewrite or internal redirection cycle while processing "/control/web/control/web/control/web/control/web/control/web/control/web/control/web/control/web/control/web/control/web/control/web/control/web/", client: 123.103.8.11, server: www.abcd.com, request: "GET / HTTP/1.1", host: "www.abcd.com"

是在無休止的循環,請問我的配置哪裡出問題了?應該如何解決?謝謝
《解決方案》

rewrite ^/(.*) /control/web/$1 last;
試試
《解決方案》

回復 #2 bs 的帖子

仍然是500 Internal Server Error,無休止循環。
《解決方案》

rewrite ^/(?!control/)(.*) /control/web/$1 ;
這個應該可以了
《解決方案》

多謝,解決了!
《解決方案》

《解決方案》


[火星人 ] 請教一個nginx rewrite或默認文檔的問題已經有400次圍觀

http://coctec.com/docs/service/show-post-21586.html