map with preserving the URL

DieterK nginx-forum at
Tue Apr 2 09:00:19 UTC 2019


I'm trying to make the URLs on my site more "friendly" with map, but I don't
understand the right way.

My config looks like this:
map $uri_lowercase $new {
  include /foobar/;

server {
  listen       443 ssl;

location / {
  if ($new) {
     rewrite ^ $new redirect;

  location ~ \.php$ {
    fastcgi_pass unix:/var/run/foobar;
    include global/php.conf;

The looks like this:
/product/foo /product.php?id=100;
/product/bar /product.php?id=200;

This also works so far, but I want to preserve the URL in the address bar.

I already tried it with break instead of redirect, unfortunately it doesn't
seem to work. (error 500)

What's the right way to do this?



Posted at Nginx Forum:,283588,283588#msg-283588

More information about the nginx mailing list