# Permalink to search.php failing to redirect to /search

**URL:** https://meta.discourse.org/t/permalink-to-search-php-failing-to-redirect-to-search/73158
**Category:** Support
**Created:** [2017 年 10 月 31 日午後 5:42 UTC](https://meta.discourse.org/t/permalink-to-search-php-failing-to-redirect-to-search/73158 "2017-10-31T17:42:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![smaffulli](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/smaffulli/32/120462_2.png) [@smaffulli](https://meta.discourse.org/u/smaffulli)
#### Post date: [2017 年 10 月 31 日午後 5:42 UTC](https://meta.discourse.org/t/permalink-to-search-php-failing-to-redirect-to-search/73158/1 "2017-10-31T17:42:17Z")

</div>

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

```plaintext
[31/Oct/2017:17:35:42 +0000] "discussion.dreamhost.com" $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`?

```plaintext
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)

```

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [2017 年 10 月 31 日午後 7:29 UTC](https://meta.discourse.org/t/permalink-to-search-php-failing-to-redirect-to-search/73158/2 "2017-10-31T19:29:07Z")

</div>

> [@smaffulli](#):
>
> shows that the permalink is somewhat processed by SearchController: is that correct?

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.

> [@smaffulli](#):
>
> Any suggestion on how to properly redirect requests from /search.php to /search?

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

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**

Maybe something along the lines of: (not tested)

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

```

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024 年 6 月 8 日午後 12:44 UTC](https://meta.discourse.org/t/permalink-to-search-php-failing-to-redirect-to-search/73158/3 "2024-06-08T12:44:01Z")

</div>

このトピックは2411日後に自動的に閉じられました。返信はもう許可されていません。
