# What is = in try\_files?

**URL:** <https://community.nginx.org/t/what-is-in-try-files/6742>\
**Category:** NGINX\
**Tags:** try-files, web-server\
**Created:** [September 10, 2025, 7:22pm UTC](https://community.nginx.org/t/what-is-in-try-files/6742 "2025-09-10T19:22:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xlf](https://avatars.discourse-cdn.com/v4/letter/x/e5b9ba/32.png) [@xlf](https://community.nginx.org/u/xlf)\
**Post date:** [September 10, 2025, 7:22pm UTC](https://community.nginx.org/t/what-is-in-try-files/6742/1 "2025-09-10T19:22:07Z")

</div>

What does `try_files $uri $uri.html = @second` do instead of `try_files $uri $uri.html @second` what is `=` for?

---

<div class="post-metadata">

**Author:** ![bit\_warrior](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/bit_warrior/32/257_2.png) [@bit\_warrior](https://community.nginx.org/u/bit_warrior)\
**Post date:** [September 12, 2025, 3:12am UTC](https://community.nginx.org/t/what-is-in-try-files/6742/2 "2025-09-12T03:12:16Z")

</div>

The directive syntax is:

```auto
try_files file1 file2 ... fallback;

```

1. Nginx checks each `fileN` **in order** (relative to `root` or `alias`).
2. If a match is found, it **serves** that file immediately.
3. If none match, it processes the final argument:
  - If it starts with `=`, it is an **HTTP status code**.

  - Otherwise, it’s interpreted as an **internal redirect** to a URI (location block).

Let’s keep watch in your config file.  
`try_files $uri $uri.html = @second;`

This means:

1. Check if there is a file at `$uri` (e.g., `/about`).

2. If not, try `$uri.html` (e.g., `/about.html`).

3. If neither exists → return **HTTP status code `@second`** ❌ ← invalid, because `@second` is not a number.

👉 Actually, this won’t work. `=something` only accepts **numeric codes** (like `=404`, `=403`, `=500`).

`try_files $uri $uri.html @second;`  
Check `$uri`.

1. Check `$uri.html`.
2. If neither exist → **internally redirect** to the named location `@second`.

---

<div class="post-metadata">

**Author:** ![alessandro](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/alessandro/32/4836_2.png) [@alessandro](https://community.nginx.org/u/alessandro)\
**Post date:** [October 2, 2025, 9:49pm UTC](https://community.nginx.org/t/what-is-in-try-files/6742/3 "2025-10-02T21:49:29Z")

</div>

Our docs actually have quite a bit of documentation and examples for [`try_files`](https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files).

The tl;dr is that the last parameter, `uri` or `=code` are used to determine what NGINX should do if the files are not found. If you use a “code”, NGINX will return that status code and the associated error page if there is one defined.

---

<div class="post-metadata">

**Author:** ![system](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/system/32/19_2.png) [@system](https://community.nginx.org/u/system)\
**Post date:** [October 9, 2025, 9:49pm UTC](https://community.nginx.org/t/what-is-in-try-files/6742/4 "2025-10-09T21:49:48Z")

</div>

Closed on October 9, 2025, 9:49pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
