5

I am having some issues getting the below to work the way I expect. What I am trying to do is take a url like

https://example.com/TOPIC/courses/details/143911 

but have it sent to php with the URI like

/index.php?/product/details/143911&original_path=/TOPIC/courses/details/143911.  

It just seems to keep giving me 404's.

location ~ ^(?P<one>.*)/(?P<two>details|scheduler)/(?P<three>.*)$ {
    try_files $uri $uri/ /index.php?/product/$two/$three&original_path=$one;
}

location ~* \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_URL $my_script_url;
    fastcgi_param SCRIPT_URI $scheme://$http_host$my_script_url;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param PHP_SELF $uri;
    fastcgi_param HTTPS $https if_not_empty;
    fastcgi_param HTTP_FRONT_END_HTTPS HTTPS;
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param REQUEST_URI $uri?$args;
    include fastcgi_params;
    fastcgi_ignore_headers "Cache-Control";
    fastcgi_ignore_headers "Expires";
    fastcgi_ignore_headers "Set-Cookie";
}

What is strange is that I can put the URL in like

https://example.com/index.php?/product/details/143911&orignial_path=/TOPIC/courses 

and it works fine.

Something else that seems strange to me is that if I implement the php-fpm status page each request, via the try_files above or entering the URL manually shows the same script and request_uri, but only the manually entry is working how I would expect.

  • That second ? is unusual - usually & is used to join elements of a query string. I wonder if encountering two ?s is confusing try_files. – Richard Smith Jan 22 '16 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.