Web Hosting Forum - Net Hosting Talk

We are a community of individuals and businesses passionate about web hosting. Let's build, learn, and grow together.

Redirecting between apache / nginx

edward

Novice
Member
Hello,

I am trying to dev API in PHP, the URL is, for example, http://127.0.0.1/api.php / search = debug on my first machine that is under apache and it works. On the other hand, on another one that uses Nginx, it does not work, in error.log I have an error that the file is not a folder

Code:
 2017 /10/ 8  10 : 08: 23 [error] 2717 # 2717: * 141605 open () "/var/www/api.php/search=debug" failed (20: Not a directory), client: 192.168.15.64 , server:, request: "GET /api.php/search=debug HTTP / 1.1", host: "127.0.0.1"

I think the problem is either with Nginx or php-frm, but I do not see how the fix it, please share if you have an idea.

Thanks :)
 
  • Advertisement
  • Hello,

    The shape of your URL is a bit "special" you would have had:
    Code:
    api.php? search = debug

    I think it would have less shocked Nginx. It is probably in the nginx.conf that we must find the solution because it tells you that it did not find a directory "search = debug"

    Try to add this (part of the configuration for Symfony) in the file nginx.conf for the site in question:
    Code:
    location / {
             # try to serve file directly, fallback to app.php 
            try_files $ uri /api.php$is_args$args; 
        }

    Source:
    Code:
    https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/

    regards :)
     
  • Advertisement
  • Advertisement

    Back
    Top