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 problemsTo redirect one HTTP URL to its HTTPS equivalent, place an exact-match location in the port-80 server block and return a permanent redirect: location = /account/login { return 301 https://$host$request_uri; }. The equals sign limits the rule to that path, while $request_uri carries the original path and query string to HTTPS. Use a prefix location for an entire path subtree, a regular-expression location for a genuine pattern, and a separate port-80 server block when every URL on a host must use HTTPS.
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 precise configuration for one URL
An exact-match location is the safest starting point when only one URL should redirect. Put the rule in the HTTP virtual server that receives the request:
As an Amazon Associate I earn from qualifying purchases.
server {
listen 80;
server_name example.com;
location = /account/login {
return 301 https://$host$request_uri;
}
}
location = /account/login matches the URI path exactly. Nginx stops its location search as soon as it finds that exact match, so a broader prefix or regular-expression rule cannot take over for that request. The return directive sends the redirect directly from the location context. Status 301 tells clients and intermediaries that the move is permanent.
With this configuration, a request for http://example.com/account/login receives a redirect to https://example.com/account/login. A request for http://example.com/account/login/extra does not match the exact location, nor does a different path such as /account/profile.
#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.
What Nginx actually matches
Location matching uses the request URI path, not the query-string arguments. The match portion of the example is therefore /account/login; parameters do not change whether the location matches.
| Location form | Use it when | Matching behavior |
|---|---|---|
location = /path |
Only one exact path should redirect | The exact match ends the location search immediately |
location /path/ |
A directory-like subtree should redirect | The prefix matches the path and its descendants |
location ~ ^/pattern$ |
A regular expression is required | Nginx evaluates the regular expression after selecting the longest matching prefix |
The query string is handled separately from matching. In the redirect target, $request_uri contains the original path and query string, which is why the basic rule preserves parameters without additional rewriting.
Recommended Free Tools
Step-by-step: redirect exactly one URL
- Identify the receiving virtual server. Find the
serverblock listening on port 80 for the intended hostname. The rule must be placed in the block that handles the HTTP request, not only in the HTTPS block. - Add an exact location. Use the complete path after the hostname, beginning with a slash:
location = /account/login. - Return the HTTPS target. Add
return 301 https://$host$request_uri;inside the location. - Check the destination server. The HTTPS virtual server must have valid TLS configuration and normal application handling for the destination URL. A redirect cannot make an unconfigured HTTPS endpoint serve the page.
- Validate the configuration. Run
nginx -tin the deployment environment. Correct any syntax or include-file errors before reloading Nginx. - Reload and inspect the response. After a successful configuration test and reload, run
curl -I http://example.com/account/login. Look for a permanent redirect status and an HTTPSLocationheader. - Check a nearby path. Test a URL that should not match, such as
http://example.com/account/profile, to confirm that selective behavior remains intact.
Testing both sides of the boundary matters. A rule can appear correct when the target path redirects but still be too broad if neighboring URLs are also being sent to HTTPS.
Preserving or changing query parameters
Use $request_uri when the redirect should retain the original path and arguments. For example, a request for http://example.com/account/login?next=%2Fbilling is redirected with the original query string included in the URI carried by $request_uri.
location = /account/login {
return 301 https://$host$request_uri;
}
Location matching still sees only the path, so /account/login?next=%2Fbilling matches the same exact location as /account/login. If the destination must discard, replace, or otherwise alter arguments, do not rely on the unchanged variable. Construct the target explicitly and review the rewrite module’s argument-handling rules before deployment.
Preservation is usually appropriate for tracking, pagination, return URLs, and application parameters. Discarding arguments may be intentional when the old query string is unsafe or no longer meaningful, but that is a URI transformation decision rather than a simple HTTPS enforcement rule.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, 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 minuteRank #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.
Redirecting an entire path subtree
When every URL below a path should move to HTTPS, use a prefix location rather than listing each child URL:
server {
listen 80;
server_name example.com;
location /private/ {
return 301 https://$host$request_uri;
}
}
This catches /private/ and descendant paths such as /private/reports while leaving unrelated paths available to their normal HTTP handling. Choose the prefix carefully: a broad prefix can include endpoints that were not intended to redirect.
A prefix location is different from an exact location. location = /private/ handles only the single path ending in /private/; location /private/ covers the subtree. Do not remove the equals sign accidentally when the requirement is one URL.
Using a regular expression for patterned URLs
Regular expressions are useful when the set of paths follows a real pattern that cannot be expressed as one fixed path or a simple subtree:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
server {
listen 80;
server_name example.com;
location ~ ^/legacy/(.*)$ {
return 301 https://$host$request_uri;
}
}
Here, the expression identifies paths beginning with /legacy/. Do not use a regex merely because it looks more powerful; exact and prefix locations are easier to read and have less complicated matching behavior.
Nginx first finds the longest matching prefix and then applies its regular-expression rules. An exact = match terminates the search immediately. When a configuration contains overlapping prefixes and regex locations, verify which block will win for every important path instead of assuming that the visually nearest declaration takes precedence.
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
When the whole host should use HTTPS
If every URL on a hostname should move from HTTP to HTTPS, a dedicated port-80 server block is clearer than a collection of conditional rewrites:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
This server-level return applies to all requests handled by that block. Keep selective path rules in the server handling the affected requests when only certain URLs require HTTPS. Separating host-wide enforcement from path-specific exceptions makes the intended scope visible and avoids accidentally redirecting an endpoint that still needs HTTP behavior.
Before enabling a host-wide redirect, confirm that the HTTPS virtual server handles every destination path and that its certificate and TLS settings are valid for each hostname listed in server_name. A universal redirect is only useful if all of its destinations are available.
return versus rewrite
Use return when each matching request receives the same redirect target. It is the direct way to emit status codes such as 301, 302, 303, and 307 from a server or location context.
location = /account/login {
return 301 https://$host$request_uri;
}
Use rewrite when a regular expression must transform the URI itself or when rewrite flow control is required:
server {
listen 80;
server_name example.com;
rewrite ^/legacy/(.*)$ https://$host/new/$1 permanent;
}
The expression captures the portion after /legacy/ and inserts it after /new/. The permanent flag produces a permanent redirect. This is a URI migration as well as an HTTPS redirect, so inspect the resulting path carefully.
Free tools Windows power users keep installed
One-click scans. No signup required.
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.
Rewrite processing also has flow-control flags. last changes the URI and starts a new location search; break stops the current rewrite processing. These controls are useful for more involved rewrite logic, but they introduce additional paths through the configuration. Avoid a rule that sends an already-HTTPS request back to HTTP, or a pair of transformations that repeatedly redirect the client.
Choosing the correct hostname in the target
The example uses $host so the redirect retains the host that Nginx accepted for the request. This is appropriate only when that host is trusted and the site intentionally serves it.
For a canonical-host policy, put the approved hostname directly in the target instead:
location = /account/login {
return 301 https://example.com$request_uri;
}
Hard-coding the canonical name prevents arbitrary host input from being reflected into a redirect. If several names are intentionally served, configure each name deliberately and decide whether each should remain in the destination or be redirected to one approved host.
Complete selective configuration example
The following example combines an exact URL, a subtree, and ordinary handling for all other HTTP paths. It illustrates scope; adapt the surrounding application directives to the existing deployment.
server {
listen 80;
server_name example.com;
location = /account/login {
return 301 https://$host$request_uri;
}
location /private/ {
return 301 https://$host$request_uri;
}
location / {
# Existing HTTP application handling remains here.
}
}
The exact location takes precedence for the single login path. The prefix location handles the private subtree. The final prefix is a fallback for requests that do not match either redirect rule. Keeping these cases separate makes later troubleshooting easier than combining them into one opaque conditional.
Best Value
Deployment and verification checklist
- Confirm the rule is in the
serverblock for the intended hostname and port. - Use
location = /pathfor one exact URL. - Use a prefix location for a directory-like subtree.
- Use a regex location only when the requirement is genuinely pattern-based.
- Prefer
return 301when the target is simply the same URI over HTTPS. - Use
rewrite ... permanentwhen the path itself must be transformed. - Confirm that the HTTPS virtual server has valid TLS configuration and can serve the destination.
- Decide explicitly whether query strings should be preserved, replaced, or removed.
- Run
nginx -tbefore reloading. - Inspect a matching request with
curl -I http://example.com/exact/path. - Inspect at least one nearby non-matching path to verify that selective behavior is preserved.
Troubleshooting common failures
The request does not redirect
Check that the request reached the intended port-80 server and hostname. A different server_name or a different listening block can make a correct location appear ineffective. Then compare the requested path with the exact string after location =; a one-character difference prevents an exact match.
Too many URLs redirect
Look for a prefix such as location /account/ where an exact location was required. Replace it with location = /account/login when only the login path belongs in the rule. Also inspect regex locations, because a broad expression can match paths outside the intended set.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →The query string disappears
Verify that the target uses $request_uri. If the configuration constructs a new URI, query arguments may need to be handled explicitly according to rewrite-module rules. Test both a request without arguments and one with several arguments.
The redirect points to an unexpected host
Review whether $host is appropriate for the deployment. If one canonical hostname is required, replace the variable with that approved hostname in the redirect target and configure the corresponding HTTPS server.
The browser reports a redirect loop
Inspect both the HTTP and HTTPS server blocks. A rule intended for port 80 must not send an already-HTTPS request back to HTTP, and a rewrite that changes the URI must not trigger a reverse transformation. Use response headers from curl -I to identify each hop.
The HTTPS destination returns an error
The redirect only changes the URL scheme. Confirm that the HTTPS virtual server has a valid certificate and normal application handling for the destination path. If the target path is not served over HTTPS, fix that server configuration before enabling the redirect.
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 →Clear out junk files and repair common Windows errorsFree Scan →Deciding which pattern to use
| Requirement | Recommended directive | Example target |
|---|---|---|
| One URL, unchanged path | Exact location with return |
location = /account/login |
| All descendants of a path | Prefix location with return |
location /private/ |
| Paths selected by a pattern | Regular-expression location with return |
location ~ ^/legacy/(.*)$ |
| Path must change while moving to HTTPS | rewrite with a permanent redirect flag |
rewrite ^/legacy/(.*)$ https://$host/new/$1 permanent; |
| Every URL on a host | Server-level return in a port-80 block |
return 301 https://$host$request_uri; |
Operational cautions
A permanent redirect can be cached by clients and intermediaries, so confirm the scope before rollout. Start with the narrowest matching construct that satisfies the requirement. If the intended policy later expands from one endpoint to a subtree or an entire host, make that scope change explicit rather than silently broadening an existing expression.
Keep the redirect rule close to the virtual server that owns the hostname. This makes configuration review easier and reduces the chance that a rule in an unrelated server block changes behavior. After every change, validate syntax, reload through the normal deployment procedure, and test both a URL that should redirect and one that should not.
Quick Recap
Key takeaways
location = /pathis the precise tool for one URL.return 301 https://$host$request_uri;performs a direct permanent redirect while retaining the original path and query string.- Prefix locations cover subtrees; regular-expression locations cover patterns and follow different priority rules.
- A dedicated port-80 server block is the clearest choice when every URL on a host must use HTTPS.
rewriteis appropriate when the URI itself must be transformed; itslastandbreakflags alter processing flow.- Validate with
nginx -t, inspect the response withcurl -I, and test both matching and non-matching paths before rollout.
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.




