Recommended Free Tools
Use an exact-match location for the URI you want to protect, and put the general rewrite in a separate prefix location. For example, this keeps /special-url out of the catch-all rewrite:
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
server {
location = /special-url {
try_files $uri =404;
}
location / {
rewrite ^ /index.php last;
}
}
The = modifier makes the location an exact URI match. NGINX stops location selection when it finds that match, so the request is handled by the exception block instead of location /. This pattern works only when the broad rewrite is inside a location; a rewrite at server scope runs before location selection and must be changed or excluded separately.
As an Amazon Associate I earn from qualifying purchases.
The exact-match pattern
An NGINX location beginning with = matches one normalized URI exactly:
location = /special-url {
try_files $uri =404;
}
NGINX checks exact locations before prefix and regular-expression locations. When it finds location = /special-url, it stops searching, so a broader block such as location / does not process that request. The exception must be placed in the same server block as the rewrite it is intended to bypass.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
The handler inside the exact location determines what “excluded” means. try_files is appropriate when the URI should resolve to a file or directory. A fixed response needs return, while an application request usually needs a named fallback location.
First determine where the rewrite runs
The most important distinction is whether the general rule is in the server context or inside a location.
Rewrite inside location /
This is the straightforward case:
server {
location = /special-url {
try_files $uri =404;
}
location / {
rewrite ^ /index.php last;
}
}
For a request to /special-url, NGINX selects the exact location and never enters the broad prefix location. Other URIs select location / and are internally redirected to /index.php by the last flag.
Rewrite at server scope
Server-level rewrite directives run sequentially before NGINX searches for a location. An exact-match location cannot undo a rewrite that has already executed:
server {
rewrite ^ /index.php last;
location = /special-url {
try_files $uri =404;
}
}
Here, the rewrite runs first. The request may be changed to /index.php before the exact exception can be selected. Move the broad rule into a location whenever possible:
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
server {
location = /special-url {
try_files $uri =404;
}
location / {
rewrite ^ /index.php last;
}
}
If moving it is not possible, exclude the URI in the server-level regular expression itself. The boundary in this example exempts exactly /special-url and also any path beginning with /special-url/:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →server {
rewrite ^(?!/special-url(?:$|/)).* /index.php last;
location = /special-url {
try_files $uri =404;
}
}
Decide deliberately whether the child-path behavior is wanted. If only the single URI should be exempt, the negative expression must use a boundary that rejects /special-url/child as well as unrelated paths.
Choose the right exception handler
Serve a fixed response or redirect with return
Use return when the exception always produces one status, body, or redirect:
location = /special-url {
return 200 "ok\n";
}
A redirect can be returned from the same server or location context. This avoids running a rewrite when the desired result is already known.
Serve a file or directory with try_files
For a static resource, check the requested path and return a not-found status when it does not exist:
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
location = /special-url {
try_files $uri $uri/ =404;
}
The first candidate checks the URI as a file, the second checks it as a directory, and =404 supplies the final response if neither exists. try_files can also internally redirect to another URI or a named location.
Send the exception to an application fallback
If the URL must bypass the general rewrite but still reach an upstream application, use a named location:
location = /special-url {
try_files $uri @app;
}
location @app {
proxy_pass http://backend;
}
This keeps the exception out of the catch-all rewrite while preserving an explicit route to the application. Replace the upstream definition with the backend used by your configuration; the important part is the named fallback rather than another broad rewrite.
When the exception covers a whole subtree
An exact match is for one normalized URI. To exempt a directory-like prefix such as /assets/, use a prefix location with ^~:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutelocation ^~ /assets/ {
try_files $uri =404;
}
After NGINX finds the longest prefix, ^~ tells it not to test regular-expression locations. Without it, a regex location elsewhere in the configuration can take precedence over the prefix and apply an unintended rewrite.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
This is different from location = /assets/, which matches only the directory URI itself and not files such as /assets/app.css.
How URI matching affects the exclusion
Query strings are not part of the location match
Location selection uses the normalized URI, not the query string. Therefore:
/special-url?x=1
still matches:
location = /special-url
You do not need a separate exact location for every query-string combination. If application behavior depends on a parameter, handle that logic after the location is selected rather than creating duplicate locations.
Free tools Windows power users keep installed
One-click scans. No signup required.
Trailing slashes are different URIs
/special-url and /special-url/ are not the same exact match. If both must bypass the rewrite, define both explicitly or use a carefully scoped prefix:
location = /special-url {
try_files $uri =404;
}
location = /special-url/ {
try_files $uri $uri/ =404;
}
If child paths should also be exempt, a prefix location may be clearer:
Best Value
location ^~ /special-url/ {
try_files $uri $uri/ =404;
}
Keep the exact location for the bare URI if it needs different behavior from its descendants.
Normalized and decoded paths need testing
NGINX matches a normalized URI. Encoded characters, repeated separators, and path normalization can therefore produce a match that is not obvious from the raw request line. Test the forms that clients, proxies, or frameworks can actually send, and do not assume that a visually similar path is covered by an exact location.
Rewrite ordering and internal redirects
Rewrite directives are processed in order. A rewrite with last changes the URI and starts another location search, so the request can pass through more than one location during one transaction. Put the exception and the general rule where their intended processing order is unambiguous.
Repeated rewrites are limited to 10 internal redirection cycles. A rule that continually changes a URI back and forth can therefore end in an internal-server-error response instead of reaching the application. Common causes include rewriting /index.php back to itself, sending a named fallback into a prefix that repeats the original rule, or using a broad pattern that also matches the rewritten URI.
Keep the fallback target outside the rewrite condition, or add a dedicated exact or prefix location for the target. Test the final URI as well as the original exception URI.
Step-by-step configuration procedure
- Find the active server block. Inspect the virtual host that receives the request and all files included from it. An exception in a different server block has no effect.
- Locate every rewrite directive. Determine whether the broad rule is in
server,location /, or a regular-expression location. The correct exclusion depends on that context. - Choose the URI boundary. Decide whether you are excluding only
/special-url, the slash form/special-url/, or the complete subtree/special-url/.... - Add the narrowest matching block. Use
location = /special-urlfor one URI, orlocation ^~ /prefix/for a subtree that must beat regex locations. - Choose the handler. Use
returnfor a fixed status or redirect,try_filesfor files and directories, or a named location for an application fallback. - Move a server-level catch-all when possible. Put the general rewrite in
location /so normal location selection can protect the exception. If it must remain at server scope, add a negative lookahead with an explicit path boundary. - Check syntax before reloading. Run the configuration test supplied by your NGINX installation, commonly
nginx -t. Correct every reported error before applying the change. - Apply the configuration. Reload NGINX using the service manager or control command used by your host, then verify that the reload completed successfully.
- Test the exact path and nearby paths. Request the bare URI, its query-string form, the trailing-slash form, a child path, and an unrelated path. Confirm both the status and the final response source.
- Inspect the rendered configuration if behavior is unexpected. An effective-configuration dump such as
nginx -Tcan reveal an included file, duplicate server block, regex location, or later rule that was not visible in the file you edited.
Verification examples
A compact test matrix catches most mistakes:
| Request | What to verify | Expected selection |
|---|---|---|
/special-url |
The exception handler runs and the broad rewrite does not. | location = /special-url |
/special-url?x=1 |
The query string does not change location selection. | location = /special-url |
/special-url/ |
Whether the slash variant is intentionally included. | Separate exact block, prefix block, or broad rule according to your design |
/special-url/child |
Whether descendants are exempt or rewritten. | Prefix exception only if configured |
/other-path |
The normal application rule still works. | General rewrite location |
/index.php |
The rewrite target does not create a loop. | Final application or static handler |
Use a request tool such as curl -i so you can see the status, redirect headers, and response headers. A body that looks correct is not enough if the request was redirected or served by an unintended fallback.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsTroubleshooting common failures
| Symptom | Likely cause | Correction |
|---|---|---|
The supposedly excluded URI still becomes /index.php. |
The rewrite runs at server scope before location selection. |
Move it into a location or exclude the path in the server-level regular expression. |
| The bare path works but the slash form is rewritten. | An exact location matches only one normalized URI. | Add location = /special-url/ or use a deliberately scoped prefix. |
| A child path is unexpectedly exempt. | A prefix exception covers more than the single URI. | Use an exact match and define slash behavior separately. |
| A regex location still handles an exempt subtree. | The prefix lacks ^~. |
Use location ^~ /prefix/ when regex locations must not override it. |
| The exception returns 404 even though the application should answer. | try_files ... =404 requires a local file or directory. |
Use a named application fallback or the handler appropriate to the route. |
| The request ends in an internal-server-error response. | Rewrite rules are cycling through the same URIs. | Check every internal redirect, keep the rewrite target out of the broad pattern, and remove the cycle. |
| Editing the visible file changes nothing. | An included configuration or different virtual host is active. | Inspect the effective configuration and confirm the request’s host and address select the edited server block. |
Choosing between an exact location and an if condition
For a single URI exclusion, an exact location expresses the routing rule directly and participates in NGINX’s normal location-selection algorithm. It also lets you select an appropriate handler—return, try_files, or a named fallback—without embedding an exception inside a broad rewrite.
An if condition can test request variables, but it does not change the fact that a server-level rewrite has already run. It is therefore not a substitute for moving a broad server rewrite into a location or correcting the server-level pattern. Use a location when the distinction is based on the request path itself; reserve conditional logic for cases that genuinely depend on variables or response processing.
Quick Recap
Configuration checklist
- The exception and broad rewrite are in the same effective
serverblock. - The one-URI exception uses
location = /path. - A subtree exception uses
^~when regular-expression locations could compete. - The handler matches the requirement: fixed response, static file, or application fallback.
- Server-level rewrites have been moved or given an explicit negative-match boundary.
- Bare, query-string, trailing-slash, child-path, and rewritten-target requests have been tested.
- The configuration passes a syntax test and has been reloaded successfully.
- No rewrite cycle can repeat more than the intended internal redirects.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




