0

so the title above is my problem.

first of all.. my domain app.com is using laravel while portal is using yii2

so app.com will go thru /var/www/app/public
what i want to do is browse http://app.com/portal and will be redirected to new folder inside /var/www/portal, but getting 404 not found.

i also read topic from

Redirecting specific URLs to different directory

nginx subdirectory as root along with other folders

but no avails

below is my config

server {
        listen 80;
        listen 443 ssl;
        #error_log  /var/log/nginx/portal.log warn;
        root /var/www/app/public;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name app.com;

       location / {
               try_files $uri $uri/ /index.php?$is_args$args;
       }

        include snippets/self-signed.conf;
        include snippets/ssl-params.conf;

        location ~*.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                expires 7d;
                log_not_found off;
                access_log off;
                fastcgi_hide_header "Set-Cookie";
        }

        location ~*.(css|js)$ {
                expires 1d;
                log_not_found off;
                access_log off;
                fastcgi_hide_header "Set-Cookie";
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location ^~ /portal {
                root /var/www;
                #index index.php;
                try_files $uri $uri/ /index.php;

        location ~ \.php$ {
                fastcgi_index index.php;
                #include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
        }

        location ~ /\.ht {
                deny all;
        }
}


*edit, error log says nothing

  • You have two PHP apps in two documents roots, you will need a nested `location` block within a `location ^~ /portal` block. See [this answer](https://serverfault.com/questions/801202/nginx-php-fpm-with-2-apps-in-subfoders/801274#801274). – Richard Smith Feb 26 '20 at 11:58
  • hi, thanks for that.. i updated my config above.. the web seems to recognize the folder.. but the problem is, the web always download php file instead of displaying.. i cant seem to figure it out.. – amanokenji Feb 26 '20 at 16:16
  • The location blocks should be nested. You’ve placed one after the other. – Richard Smith Feb 26 '20 at 16:27

0 Answers0