Home > Backend Development > PHP Tutorial > nginx 重定向的问题,怎么添加二级目录?

nginx 重定向的问题,怎么添加二级目录?

WBOY
Release: 2016-06-06 20:09:26
Original
1227 people have browsed it

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

现在想增加网校培训模块,为了保持 以前的功能 ,及相应的微信授权等功能 ,现在希望再配置一个www.a.com/edu,目前设置 的配置如下,发现存在问题除了首页其它不能正常跳转,页面中的静态文件无法正常跳转,请教高手帮我改一下

location /edu {

<code>    alias html/soho/web;
    index app.php;

    try_files $uri @rewriteapp; </code>
Copy after login
Copy after login

}

<code>location @rewriteapp {
   root html/soho/web/;
   rewrite ^\/edu\/(.*)$ /app.php/$1 last;</code>
Copy after login
Copy after login

}

<code>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;
</code>
Copy after login
Copy after login

}

<code>                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</code>
Copy after login
Copy after login

点击并拖拽以移动

回复内容:

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

现在想增加网校培训模块,为了保持 以前的功能 ,及相应的微信授权等功能 ,现在希望再配置一个www.a.com/edu,目前设置 的配置如下,发现存在问题除了首页其它不能正常跳转,页面中的静态文件无法正常跳转,请教高手帮我改一下

location /edu {

<code>    alias html/soho/web;
    index app.php;

    try_files $uri @rewriteapp; </code>
Copy after login
Copy after login

}

<code>location @rewriteapp {
   root html/soho/web/;
   rewrite ^\/edu\/(.*)$ /app.php/$1 last;</code>
Copy after login
Copy after login

}

<code>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;
</code>
Copy after login
Copy after login

}

<code>                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</code>
Copy after login
Copy after login

点击并拖拽以移动

研究了两天终于弄好了,代码放到/edu/web/目录下
主要是找到了调试方法,error_log logs/error.log debug;
增加上debug,可以看到详细的调试情况

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

<code>            alias html/edu/web;
    index app.php;

    try_files $uri @rewriteapp; </code>
Copy after login

}

<code>location @rewriteapp {
   rewrite ^/edu/web/(.*)$ /edu/web/app.php/$1 last;</code>
Copy after login

}

<code>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;
</code>
Copy after login

}

<code>                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`</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template