首頁  >  問答  >  主體

fastcgi - 請教一個nginx的二級目錄配置問題

location ~ ^/bbs/.+\.php$ {
        alias   /home/www/esotalk/;
        rewrite /bbs/(.*\.php?) / break;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/www/esotalk$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~ ^/bbs($|/.*) {
        alias   /home/www/esotalk/;
        index   index.php index.html;
    }

配置如上,

程式為 esoTalk,檔案放在 /home/www/esotalk/ ,

擺安裝檔進去了,當訪問 /bbs 時,本來應該跳轉去 /bbs/?p=install/info 的,但是跳轉成了 /?p=install/info ,

求解決方法,謝謝。

黄舟黄舟2712 天前960

全部回覆(2)我來回復

  • PHP中文网

    PHP中文网2017-05-16 17:28:07

    如果沒記錯的話,應該是這樣

    location ~ ^/bbs/.+\.php$ {
        alias   /home/www/esotalk/;
        rewrite /bbs/(.*\.php?) /bbs/ break;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/www/esotalk$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~ ^/bbs($|/.*) {
        alias   /home/www/esotalk/;
        index   index.php index.html;
    }
    

    回覆
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:28:07

    # Achais个人博客
    server {
        listen 80;
        server_name achais.com www.achais.com;
        root /a/apps/default/achais;
        index index.php index.html index.htm;
    
        # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.
        location ~ .*\.php(\/.*)*$ {
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            access_log     /a/apps/nginx/logs/achais/main.access.log main;
        }
    }
    
    server {
        listen 80;
        server_name me.990t.cn;
        root /a/apps/default/achais;
        index index.php index.html index.htm;
    
        # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.
        location ~ .*\.php(\/.*)*$ {
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            access_log     /a/apps/nginx/logs/achais/main.access.log main;
        }
    }
    

    不同的二級網域用server_name辨別就行了.
    location ~ ..php(/.)*$ {
    # 這個location規則是針對 typecho 的.
    }

    回覆
    0
  • 取消回覆