I am trying to rewrite a URL in a WordPress website running Nginx so that the last subdirectory is transformed into GET-parameter:
http://mydomain/property/aid/1234/ to http://mydomain/property/?aid=1234/
I tried with add_rewrite_rule in WordPress, but it didn't work as it didn't create a new $_GET entry.
Then I tried the following Nginx rule:
rewrite ^(/property/.*)/aid/(.*)$ /$1/?aid=$2 break;
which seems to have no effect at all.
Any suggestions?
Suppose the document root is
/www/yourproject/public. Then the configuration for PHP-FPM may look like the following:In this configuration, the requests are processed by
/www/yourproject/public/property/index.php.Sample
index.phpSample output for
/property/aid/1234You can replace
fastcgi_passandfastcgi_indexdirectives with aproxy_pass, for instance.