Home > Backend Development > PHP Tutorial > Add subprojects to nginx subdirectory, css and other resources cannot be accessed

Add subprojects to nginx subdirectory, css and other resources cannot be accessed

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-10-12 10:04:11
Original
2167 people have browsed it

There are two projects, one is from phpcms, and the other is from the yii2.0 framework. The server uses nginx. Now I want to take the yii project directly as a subdirectory and then use it through the http://domain.com/ subdirectory. to access, but the index can be accessed through the configuration/subdirectory, but the resource files of the page such as pictures, css, etc. cannot be loaded. The picture link is http://domain.com/subdirectory/public/images/blue_icon.png, but it still does. Redirect to index.php under the subdirectory. What is the problem?

<code>server{
    listen 80;
    server_name domain.com;
    root   /Users/xxx/www/project;
    index index.php;
    
    location /{
        try_files $uri $uri/ /index.php?$args;
        autoindex on;
    }    
    location /blog{
        index index.php index.html;
        try_files $uri $uri/ /blog/index.php?$args;
        autoindex on;
    }
    location ~ ^(.+\.php)(.*)$ {
        root   /Users/xxx/www/project;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}</code>
Copy after login
Copy after login

Reply content:

There are two projects, one is from phpcms, and the other is from the yii2.0 framework. The server uses nginx. Now I want to take the yii project directly as a subdirectory and then use it through the http://domain.com/ subdirectory. to access, but the index can be accessed through the configuration/subdirectory, but the resource files of the page such as pictures, css, etc. cannot be loaded. The picture link is http://domain.com/subdirectory/public/images/blue_icon.png, but it still does. Redirect to index.php under the subdirectory. What is the problem?

<code>server{
    listen 80;
    server_name domain.com;
    root   /Users/xxx/www/project;
    index index.php;
    
    location /{
        try_files $uri $uri/ /index.php?$args;
        autoindex on;
    }    
    location /blog{
        index index.php index.html;
        try_files $uri $uri/ /blog/index.php?$args;
        autoindex on;
    }
    location ~ ^(.+\.php)(.*)$ {
        root   /Users/xxx/www/project;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}</code>
Copy after login
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template