How to write the rollback target instruction in order when static files fall onto the Web server?

📅 October 12, 2026 👁️ 9

The instruction (try_files) that is responsible for finding files in order when static pseudo-URLs fall onto the web server should be written as 'the last parameter is an address', not to list a non-existent file. Its semantics are to check the existence of files in the given order, using the first found file to handle the request in the current context; if all are not found, then an internal redirection is performed to the address given by the last parameter.

What order does this instruction find files?

Three key points determine the writing style:

  • Order-sensitive: judged one by one from left to right, the first existing one is adopted, and the others are no longer considered.
  • Current context processing: After a hit, it will not go through the position matching again, so when rewriting the path in the position block, pay attention to the scope of action;
  • The last parameter is a fallback: it does not participate in the existence judgment and is directly treated as an internal redirection target.

How to choose between two syntax forms

Writing style Meaning Suitable for scenes
File list plus an address at the end Internal redirection to this address when no hits Static redirection is unifiedly handed over to the backend entry processing
File list plus a status code at the end Directly return this status code when no hits Static resources, thumbnails and such should not enter the backend requests

The scenario of writing back as a status code, where the request will not enter the backend again, saving the cost of an unnecessary explanation; writing back as a backend address scenario, it is only necessary to ensure that the address can be processed in the same block.

Typical rollback chain in the pseudo-static scenario

The pseudo-static address generated by the content system does not correspond to the real existing file on the disk, so the search chain should be arranged in the order of 'let the real file take precedence first, and finally fall to the entry'.

  1. The request path itself - hits the existing static files (images, attachments, generated HTML);
  2. Paths ending with a slash - used for directory existence judgment;
  3. The backend entry address plus query string - the remaining address is handed over to the content system for interpretation.

The third item is the fallback target, which must be in address format and cannot be written as a status code, otherwise the entire site's pseudo-static pages will return an error directly.

The slash convention for directory judgment

To determine if a directory exists, a slash should be added at the end of the name. Without this slash, files and directories with the same name will be confused; if a slash is used on a file, it will cause the file that should exist to be permanently judged as non-existent.

The connection with internal redirection and deployment methods

This instruction handles the 'which file does the address fall into', and the background 301 redirect handles the 'moving the old address to the new address'. The two layers should not pretend to be each other: use a lookup chain to implement the jump, which will lose the explicit status code semantics, and the抓取方 cannot read the relocation relationship from the response.

The deployment method also affects the modifiability of this layer. When deploying with Docker images or panels, the server configuration is often included in the image or site template, and changing files directly in the container will disappear during the next rebuild. The correct approach is to write the pseudo-static rules and lookup chains in a versionable configuration mount, and then verify each address individually after making changes.

Common questions

Why are there still forty-four when the fallback target is written as the backend address?A common reason is that there is no corresponding processing block for the backend address in the same position block, and after internal redirection, it is intercepted by the same rule again, forming an unreturnable loop.

Should the static pages that have already been generated be placed in the progress directory for judgment?It should be placed in front. Only by making the generated static files take precedence can the benefits of pseudo-static 'generate on demand and reuse' be reflected.

Can it be used to replace the pseudo-static rules?No. This command only does file existence judgment and fallback, and the correspondence relationship between the address and parameters is still defined by the pseudo-static rules within the site.

Related articles

When scheduling content and batch importing at the same time, what should be paid attention to in content scheduling?

Scheduled release and batch import together, the key to scheduling is in state division: the documents imported in batch are first stored as draft or pending release, and then released peak-time with scheduled release. This article explains the meaning of each of the four document states: formal, draft, pending release, and recycling bin, how to verify the draft link with preview parameters, the troubleshooting sequence of missing fields in import, and how to recover deleted content through the recycling bin.

2026-10-12

Whether to install the preview version on the production station, and how to choose between Release Candidate and formal version

The candidate version is at the final stage of the release process, the purpose is to let people verify the upcoming packaged final version, not the version for daily use on production stations. This article uses the recent example of Joomla simultaneously releasing 6.2 candidate version and 5.x, 6.x dual branch security repair announcements to explain where the candidate version should run, which branch to upgrade first when running dual version lines in parallel, and the backup and rollback points that must be prepared before the upgrade.

2026-10-12

Forms and comments are flooded by robots, besides the captcha, what else can be done to add several layers?

Form and comment anti-robot spambot prevention, CAPTCHA only blocks the automatic submission layer, and cannot block scripts that have bypassed verification and low-cost manual submissions. The layered叠加 can be: submission verification (reCAPTCHA CAPTCHA, timestamp and honeytrap fields), content filtering (sensitive word filtering, keyword replacement, content review), publishing strategy (review before posting, pending publication status, frequency limit and login threshold). This article explains the limitations of each layer, as well as what to adjust when all three layers cannot block it.

2026-10-12

How to fill in the last modified time in the sitemap so that it is easy to be accepted.

The last modified time in the sitemap should be filled in according to the actual change: the protocol requires the use of W3C Datetime format, which can only be written as a date; changefreq and priority are defined as hints rather than instructions, and full-site refresh will only make the crawler treat this field as noise. This article explains the protocol meaning of this field, the four common ways it is filled incorrectly, how to obtain the real change time from the content status, and the time scope to be noted when配合 with timed publishing.

2026-10-12

After container deployment, who follows up on the Web server patch in the base image?

After container deployment, the patch of the Web server brought by the base image is still followed up by the site operator, and the responsibility will not shift because the image is built by someone else. It should be divided into three layers: application layer, image layer, and reverse proxy layer, with different repair versions and update rhythms at each layer. This article provides the division of responsibilities for the three layers, why an unchanged image tag is equal to no upgrade, and the operation sequence of rebuild and grayscale.

2026-10-12

Where is the cost difference between adding a field and modifying a field in the content model?

The custom content model supports flexible content structures, but the cost of adding a field and modifying a field is not the same: adding a field mainly affects the input method and template value, while modifying a field will affect the historical data of published content, template value, and in-site links. This article provides four items to confirm before going online, batch approaches when necessary to make changes, and a checklist to run after the changes are made.

2026-10-12

After the article's title is changed, should the address change as well, and how should the old links that have been included be handled?

The title change may also change the address, depending on what the static address is derived from: when split by number or time slice, the address can remain unchanged, and a new address will be generated when an alias is created from the title. This article provides two judgment methods for these situations, as well as the order of handling old links - retain the original address, add a 301 redirect, update the sitemap and active push, and review the in-site anchor text, and also specifies which positions to check after the change.

2026-10-12

The words in the keyword library appear repeatedly in the text, and whether the anchor text will be too dense.

The automatic anchor text handling of in-site keywords is based on hits, the wider the vocabulary, the more frequently the same word appears in the text, the denser the generated internal links will be, and the readability of the text and the distribution of link weights will be diluted. This article explains why the density goes out of control, the three configuration ideas to check before going online, how to manage the keyword library hierarchically, and its relationship with sensitive word filtering and keyword replacement in sequence.

2026-10-12