Free tools Windows power users keep installed
One-click scans. No signup required.
NGINX does not read Apache .htaccess files. If a site moved from Apache to NGINX, the Apache rewrite rules are inert unless you translate them into the active NGINX server and location configuration. Without an equivalent fallback, NGINX looks for a literal file or directory and commonly returns 404 for every “pretty” URL.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
The usual front-controller fix is try_files $uri $uri/ /index.php?$args;, but that line succeeds only when the correct virtual host, location, document root (or alias), and application handler are in use. Use the workflow below to identify the loaded configuration, translate each rule by its intent, validate it, and verify the result in the logs.
As an Amazon Associate I earn from qualifying purchases.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsWhy an Apache rewrite becomes a 404 on NGINX
Apache evaluates .htaccess in the directory that contains the request. A file in the document root can therefore change how Apache handles requests without changing the main server configuration. NGINX has no equivalent per-directory file that it discovers automatically. Leaving .htaccess beside your site files does nothing on NGINX.
Suppose the browser requests /profiles/alex. Apache may use a rule in .htaccess to send that URI to an application entry point. NGINX instead selects a server block, chooses the most specific matching location, and performs normal file lookup under that block’s root or alias. If no real file or directory exists and no translated fallback is configured, the lookup ends in a 404 before the application sees the request.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
The fix is configuration, not a change to the browser URL and usually not a change to application code. Put the equivalent logic in the virtual host that actually serves the failing hostname. Then make sure the final URI has a handler: a static file, a PHP-FPM location, a proxy upstream, or another application endpoint.
First identify the configuration NGINX is really using
Editing a file is pointless if it is not included by the running NGINX instance or if another virtual host wins the request. Establish the active binary, configuration path, host, and logs before translating rules.
- Identify the binary and build. Run
nginx -vfor the version andnginx -Vfor the build arguments, including the compiled default configuration path. - Find the effective virtual host. Locate the
serverblock whoselistenandserver_namematch the failing host. Check included files as well as the main configuration. - Trace the URI’s location selection. A regular-expression location for PHP, an exact-match location, or a nested prefix can take precedence over the
location /block where you addedtry_files. - Record the active root or alias. The path used for existence checks must be the directory that contains the deployed files, not necessarily the project directory.
- Locate access and error logs. Their paths can be set globally or per virtual host. Use the entries for one failing request while testing, rather than relying on a cached browser result.
On most installations, validate a proposed change with nginx -t before reloading through the service manager. A successful syntax test proves that NGINX can parse the file; it does not prove that the intended virtual host or location will handle the request, so continue with a real request and log inspection.
Choose the NGINX directive that matches the job
Apache rules often combine several jobs. Translate the intent instead of converting every line mechanically into an if statement.
| Need | Preferred NGINX construct | What happens to the client | Typical failure to check |
|---|---|---|---|
| Send a fixed moved URL or status | return |
Usually an external redirect or an immediate response | Wrong target, status code, or host |
| Transform a URI with a regular expression | rewrite |
May be an internal redirect or an external redirect, depending on flags and replacement | Rule order, a loop, or unintended query-string handling |
| Test whether a file or directory exists, then fall back | try_files |
Serves the first existing candidate or internally redirects to the final parameter | Wrong root/alias, location precedence, or missing fallback handler |
| Pass an application request to an upstream | A matching location with the deployment’s PHP-FPM or proxy_pass setup |
The application or upstream generates the response | The fallback URI has no matching upstream handler |
Use try_files for the common front-controller pattern
Apache configurations frequently test that the requested path is not a real file and not a real directory, then send everything else to an entry point. NGINX expresses that test directly:
server {
root /var/www/example/public;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
# Use the PHP-FPM settings appropriate to this deployment.
}
}
$uri checks the requested path as a file under the active root or alias. $uri/ checks it as a directory. If neither candidate exists, the last parameter performs an internal redirect to /index.php. The ?$args suffix preserves the original query arguments in this common pattern.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
This is a pattern, not a universal copy-and-paste server block. The PHP location must point to the correct PHP-FPM socket or upstream and must protect the deployment’s intended script rules. If the application entry point is elsewhere, use that path. If the application is behind an HTTP upstream, the last step may be a named location or a proxy handler instead of /index.php.
Static sites: make the failure explicit
A static site normally has no application endpoint to receive an unknown URI. Its fallback should therefore be an explicit status, for example:
location / {
try_files $uri $uri/ =404;
}
Use a static document fallback only when the site is designed for one. Sending every missing asset or page to an HTML shell can hide broken links and make debugging harder.
Reverse-proxied applications
If the application is served by an upstream process, keep the existence check and upstream handoff in the locations appropriate to that deployment. A failed try_files fallback that points to a URI with no proxy location can still end in 404 even though the upstream itself is healthy. Confirm that the fallback URI matches a location containing the required proxy_pass or named-location handoff.
Translate familiar Apache rules by intent
Apache “not a file and not a directory” conditions
The usual Apache front-controller logic resembles:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
In NGINX, the direct equivalent is normally:
location / {
try_files $uri $uri/ /index.php?$args;
}
Do not add an extra if merely to imitate each Apache condition. try_files performs the existence checks against the current filesystem mapping and makes the fallback order visible.
Permanent or temporary redirects
For a fixed redirect, use return rather than a regular expression:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
location = /old-page {
return 301 /new-page;
}
The client receives a redirect and requests the new URI separately. Keep the exact status and destination appropriate to the move; a permanent redirect should not be used for a temporary maintenance route.
Regular-expression URI changes
Use rewrite when a pattern must transform a URI. Rules run in order, and a rewrite can cause NGINX to search for a new matching location. Keep the expression narrow and verify the resulting location rather than assuming the original block will continue processing it.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Query arguments require special care. Depending on the replacement string and flags, NGINX may retain existing arguments, replace them, or discard them. A trailing question mark in a replacement changes that behavior. Test a URL with a query string and inspect the access log so that tracking, pagination, or authentication parameters are not silently lost.
NGINX limits repeated URI-rewrite processing to ten cycles. If logs show repeated internal redirects or a request reaches that limit, look for two locations rewriting to each other, a replacement that matches its own input, or a fallback that re-enters the rewrite block.
Check root, alias, and location precedence
Most apparently correct try_files rules fail because they check the wrong filesystem path. With root, NGINX appends the request URI to the configured directory. An application deployed in /var/www/example/public must therefore use that public directory if its assets and entry point live there. Pointing at the project root can make every candidate miss.
alias maps a location to a different filesystem path and has different path-joining behavior. Review the directive that applies in the exact location handling the request; do not infer it from a higher-level block if a nested location overrides it. A typo, missing trailing path component, or alias that maps outside the deployed release directory can produce the same 404 symptom as a missing rewrite.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Location selection also explains why a rule appears to work for one URI but not another. An exact match such as location = /, a prefix with special processing, or a regular-expression location can bypass the generic location /. Verify the failing URI in the selected block, not just the block you intended to edit.
Seven-step 404 troubleshooting workflow
- Reproduce one clean request. Test a known existing static file and one failing pretty URL. Record the status, host, path, and query string for each.
- Confirm the running instance. Use
nginx -vandnginx -Vto identify the binary and configuration path. If multiple instances or containers exist, make sure the command targets the one serving the request. - Validate before reload. Run the deployment’s configuration test, commonly
nginx -t. Fix every syntax or include error before reloading through the service manager. - Confirm the winning server block. Check
listen,server_name, and any default-server behavior. A request sent to another virtual host will never reach the rule you changed. - Confirm the winning location and filesystem mapping. Inspect location precedence plus the effective
rootoralias. Ensure the expected static file, directory, and application entry point exist at those paths. - Verify the final fallback handler. Request the fallback URI directly. If
/index.phpitself returns 404, the issue is the PHP location, script path, or deployment root rather than the original pretty URL. - Read both logs while repeating the request. Access-log status and URI data show what was requested; error-log messages can expose missing files, rewrite loops, permission problems, or an upstream failure. Compare the static and dynamic requests to isolate where their paths diverge.
Common migration mistakes and precise fixes
Leaving Apache syntax in place
RewriteEngine On, RewriteCond, and RewriteRule are Apache directives. NGINX will not interpret them from a document-root file. Remove the expectation that editing .htaccess changes behavior and place an NGINX translation in the included virtual-host configuration.
Converting every condition to if
Blind one-for-one conversion can create unexpected processing order and makes filesystem checks harder to reason about. Prefer try_files, an appropriate location, or a server-level decision when that expresses the intent. Reserve conditional logic for a case that those constructs cannot represent clearly.
Putting the rule in the wrong virtual host
A staging hostname, an IPv6 listener, and a production hostname can load different files. Confirm the exact host and port in the request and ensure the edited file is included by that server block.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Using the project root instead of the public root
Framework deployments often keep the web-facing entry point in a subdirectory such as public. Set root to the directory that should be exposed and verify that both the requested assets and fallback entry point are below it.
Omitting the handler after a successful rewrite
A rewrite can produce the intended URI while the next location still has no PHP-FPM or proxy configuration. Request the destination directly and make sure its handler is present, reachable, and mapped to the same release.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Changing query arguments unintentionally
A replacement that changes argument behavior can break searches, pagination, signed links, or login callbacks. Test both a URL with no query string and one with several parameters, then compare the application’s received request with the original access-log line.
Creating a rewrite loop
When a rewritten URI matches the same rule again, NGINX can cycle through locations until the ten-cycle limit is reached. Make the pattern exclude its own output, simplify overlapping rules, and inspect error-log entries for repeated internal redirects.
How to tell whether the 404 is NGINX or the application
A missing static file under the active root is handled by NGINX before any application code runs. A request that reaches an application entry point can produce an application-generated 404 instead. The status code alone does not distinguish them.
Compare the response body, access-log URI, and error-log entry. Then request the fallback endpoint directly. If the direct endpoint fails, repair its handler, script path, upstream, or deployment root. If it succeeds while the pretty URL fails, return to location selection and the try_files candidate order.
Pre-reload checklist
- The active NGINX instance and included configuration file are identified.
- The failing hostname selects the intended
serverblock. - The failing URI reaches the location containing the translated rule.
rootoraliaspoints to the deployed web-facing directory.- Static files and directories are tested before the fallback.
- The fallback URI has a working PHP-FPM, proxy, named-location, or static handler.
- Query-string behavior has been tested with representative parameters.
nginx -tpasses before reload.- Access and error logs are monitored during a fresh request.
- No rewrite sends the request back into a loop.
The practical fix in one sentence
Stop treating .htaccess as an active configuration file, translate its purpose into the correct NGINX server/location block, use try_files for file-or-directory checks and application fallback, then validate the loaded configuration and logs with the actual host and URI.
Quick Recap
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.
Recommended Free Tools




