Permalink to search.php failing to redirect to /search

I noticed today that the permalink from search.php to External URL /search is not working properly. I get displayed a blank page, no html at all.

nginx throws a 406 error

[31/Oct/2017:17:35:42 +0000] "" $IP.IP.IP.IP "GET /search.php HTTP/2.0" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0" "-" 406 211 "-" 0.379 0.379 "-"

the error on rails log shows that the permalink is somewhat processed by SearchController: is that correct? Any suggestion on how to properly redirect requests from /search.php to /search?

Started GET "/search.php" for $IP.IP.IP.IP at 2017-10-31 17:20:17 +0000
Processing by SearchController#show as 
Completed 406 Not Acceptable in 321ms (ActiveRecord: 43.6ms)

I’m afraid so, since there is already a Discourse(Rails) route named /search: it hits the SearchController before it can be processed by the PermalinkController.

The .php part is considered (mistaken) as the desired response format, thus the 406.

There could be better solutions, but I think you’ll have to handle the redirect on NGINX, before it gets to Discourse:

Maybe something along the lines of: (not tested)

location = /search.php {
  return 301 /search?$args;