Mobile app version of vmapp.org
Login or Join
Goswami781

: Using Nginx to rewrite a friendly URL to index.php handler gives 404 error I apologize because I accidentally posted this question as an unregistered user and cannot comment, so I am posting

@Goswami781

Posted in: #CleanUrls #Error #Nginx #UrlRewriting

I apologize because I accidentally posted this question as an unregistered user and cannot comment, so I am posting it again.

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
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
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.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Goswami781

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme