nginx 重新導向的問題,怎麼添加二級目錄?

來源:互聯網
上載者:User
關鍵字 nginx php
公司已有一個主站www.a.com。

現在想增加網校培訓模組,為了保持 以前的功能 ,及相應的授權等功能 ,現在希望再配置一個www.a.com/edu,目前設定 的配置如下,發現存在問題除了首頁其它不能正常跳轉,頁面中的靜態檔案無法正常跳轉,請教高手幫我改一下

location /edu {

    alias html/soho/web;    index app.php;    try_files $uri @rewriteapp; 

}

location @rewriteapp {   root html/soho/web/;   rewrite ^\/edu\/(.*)$ /app.php/$1 last;

}

location ~ ^/udisk {    internal;    root html/soho/app/data/;}location ~ ^/(app|app_dev)\.php(/|$) {    fastcgi_pass   php_processes;    include        fastcgi_params;    fastcgi_param  SCRIPT_FILENAME  html/soho/web$fastcgi_script_name;    fastcgi_split_path_info ^(.+\.php)(/.*)$;    fastcgi_param  HTTPS              off;    fastcgi_param HTTP_X-Sendfile-Type X-Accel-Redirect;    fastcgi_param HTTP_X-Accel-Mapping /udisk=html/soho/app/data/udisk;    fastcgi_buffer_size 128k;    fastcgi_buffers 8 128k;

}

                location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {                                expires 3y;                                access_log off;                                gzip off;                                }                                location ~* \.(css|js)$ {                                access_log off;                                expires 3y;                                }                                location ~ ^/edu/files/.*\.(php|php5)$ {                                deny all;                                }                ########edusoho

點擊並拖拽以移動

回複內容:

公司已有一個主站www.a.com。

現在想增加網校培訓模組,為了保持 以前的功能 ,及相應的授權等功能 ,現在希望再配置一個www.a.com/edu,目前設定 的配置如下,發現存在問題除了首頁其它不能正常跳轉,頁面中的靜態檔案無法正常跳轉,請教高手幫我改一下

location /edu {

    alias html/soho/web;    index app.php;    try_files $uri @rewriteapp; 

}

location @rewriteapp {   root html/soho/web/;   rewrite ^\/edu\/(.*)$ /app.php/$1 last;

}

location ~ ^/udisk {    internal;    root html/soho/app/data/;}location ~ ^/(app|app_dev)\.php(/|$) {    fastcgi_pass   php_processes;    include        fastcgi_params;    fastcgi_param  SCRIPT_FILENAME  html/soho/web$fastcgi_script_name;    fastcgi_split_path_info ^(.+\.php)(/.*)$;    fastcgi_param  HTTPS              off;    fastcgi_param HTTP_X-Sendfile-Type X-Accel-Redirect;    fastcgi_param HTTP_X-Accel-Mapping /udisk=html/soho/app/data/udisk;    fastcgi_buffer_size 128k;    fastcgi_buffers 8 128k;

}

                location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {                                expires 3y;                                access_log off;                                gzip off;                                }                                location ~* \.(css|js)$ {                                access_log off;                                expires 3y;                                }                                location ~ ^/edu/files/.*\.(php|php5)$ {                                deny all;                                }                ########edusoho

點擊並拖拽以移動

研究了兩天終於弄好了,代碼放到/edu/web/目錄下
主要是找到了調試方法,error_log logs/error.log debug;
增加上debug,可以看到詳細的調試情況

=`########edu eduweb
location /edu/web {

            alias html/edu/web;    index app.php;    try_files $uri @rewriteapp; 

}

location @rewriteapp {   rewrite ^/edu/web/(.*)$ /edu/web/app.php/$1 last;

}

location ~ ^/udisk {    internal;    root html/edu/app/data/;}location ~ ^/edu/web/(app|app_dev)\.php(/|$) {    fastcgi_pass   php_processes;            fastcgi_split_path_info ^(.+\.php)(/.*)$;    include fastcgi_params;    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;    fastcgi_param  HTTPS off;    fastcgi_param HTTP_X-Sendfile-Type X-Accel-Redirect;    fastcgi_param HTTP_X-Accel-Mapping /udisk=html/edu/app/data/udisk;    fastcgi_buffer_size 128k;    fastcgi_buffers 8 128k;

}

                location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {                                expires 3y;                                access_log off;                                gzip off;                                }                                location ~* \.(css|js)$ {                                access_log off;                                expires 3y;                                }                                location ~ ^/edu/files/.*\.(php|php5)$ {                                deny all;                                }                ########edu`
  • 相關文章

    聯繫我們

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