What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
Put every source hostname in a dedicated Nginx server block and return a redirect to the single canonical host:
server {
listen 80;
server_name www.example-one.com www.example-two.com www.example-three.com;
return 301 https://example.com$request_uri;
}
The $request_uri variable carries the original path and query string, so a request such as /docs/setup?lang=en arrives at https://example.com/docs/setup?lang=en. Configure the canonical non-www site separately, and add an HTTPS redirect block with certificates when clients can connect to the www names over TLS.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows 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 reinstallUse a dedicated redirect server block
Nginx selects a virtual server by matching the request’s Host header against server_name. When the set of www domains is known, list each exact hostname in one redirecting block. This is clearer and easier to audit than conditional rewrite logic.
server {
listen 80;
server_name www.example-one.com www.example-two.com www.example-three.com;
return 301 https://example.com$request_uri;
}
Every hostname on the server_name line receives the same permanent redirect. The destination is the non-www HTTPS hostname, while $request_uri preserves the complete original URI, including its query arguments.
#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.
Keep the canonical site in its own block
The destination should have a normal site configuration rather than sharing the redirect block:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/ssl/example.com/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/privkey.pem;
# Use the configuration appropriate for your application:
# root /var/www/example;
# proxy_pass http://127.0.0.1:3000;
}
Replace the certificate paths and application directives with the values used by your deployment. The canonical block is where Nginx serves files, proxies to an application, or applies the rest of your production policy.
Free tools Windows power users keep installed
One-click scans. No signup required.
Why $request_uri preserves links correctly
Nginx’s return directive can issue a 301 response directly from the server context. In the target URL, $request_uri represents the original URI, including the path and arguments. That means these requests map as follows:
| Request | Location returned |
|---|---|
http://www.example-one.com/ |
https://example.com/ |
http://www.example-two.com/products/item-7 |
https://example.com/products/item-7 |
http://www.example-three.com/search?q=nginx&page=2 |
https://example.com/search?q=nginx&page=2 |
Do not replace $request_uri with only a slash unless you intentionally want every source URL to land on the home page. A redirect that drops the path can break bookmarks, inbound links, feeds, and application routes.
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.
Configure HTTP and HTTPS source names
An HTTP redirect block handles connections received on port 80. An HTTPS client first performs a TLS handshake on port 443, before Nginx can send an HTTP redirect. Therefore, every www hostname that users can access over HTTPS needs a certificate covering that name and a matching HTTPS server block.
HTTP source requests
server {
listen 80;
server_name www.example-one.com www.example-two.com www.example-three.com;
return 301 https://example.com$request_uri;
}
This is a one-hop conversion from an HTTP www URL to the final HTTPS non-www URL.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsHTTPS source requests
server {
listen 443 ssl;
server_name www.example-one.com www.example-two.com www.example-three.com;
ssl_certificate /etc/ssl/www-example/fullchain.pem;
ssl_certificate_key /etc/ssl/www-example/privkey.pem;
return 301 https://example.com$request_uri;
}
The certificate presented in this block must be valid for all names covered by the block. You can use a certificate with multiple subject alternative names or an appropriate wildcard, provided it actually covers the hostnames clients request. Without certificate coverage, browsers and other TLS clients can reject the connection before receiving the redirect.
One hop versus two hops
Some deployments first redirect HTTP to HTTPS on the same www hostname and then redirect the HTTPS www URL to the non-www host. Others send HTTP directly to the final canonical HTTPS URL. Choose deliberately:
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.
| Design | Responses | Requirements | When it fits |
|---|---|---|---|
| Direct canonical redirect | One 301 response from HTTP www to https://example.com$request_uri |
Port 80 source block; canonical HTTPS site; no TLS handshake is needed for the HTTP request | Most efficient path when the final URL is known and you want to avoid an extra round trip |
| HTTP upgrade, then host redirect | Two responses: HTTP www to HTTPS www, then HTTPS www to HTTPS non-www | HTTPS source block and a certificate for every www name | Useful when an existing policy or tooling requires a separate protocol upgrade |
For HTTPS www traffic, both designs still require the TLS certificate before any redirect can be returned.
Exact names, wildcards, and regular expressions
Nginx supports exact names, wildcard names, and regular-expression names. Matching method affects how narrowly the redirect applies and how easy it is to review.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →| Matcher | Example | Scope and auditability | Matching cost |
|---|---|---|---|
| Explicit names | server_name www.alpha.example www.beta.example www.gamma.example; |
Only the listed hosts redirect; the mapping is immediately visible and difficult to overmatch | Most efficient for a finite set of frequently used names |
| Wildcard | server_name *.example.com; |
Covers a deliberate subdomain pattern; review whether every matching subdomain should become the same canonical host | Efficient, but broader than an explicit list |
| Regular expression | server_name ~^www.(.+).example.net$; |
Can express complex patterns, but may capture hosts you did not intend to redirect | Regular expressions are evaluated sequentially and are slower and less scalable than exact or wildcard matching |
Use the explicit list when the domains are known. A wildcard or regex is appropriate only when the broad set is intentional and documented. With regex rules, order matters because Nginx tests them sequentially; keep the expression narrow and place it where it cannot unexpectedly intercept another site.
Handling several domains that share one canonical host
A complete configuration commonly has four roles: HTTP redirects for the source names, HTTPS redirects for those names, the canonical HTTPS site, and (optionally) a policy for unknown hosts.
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
# HTTP www aliases
server {
listen 80;
server_name www.example-one.com www.example-two.com www.example-three.com;
return 301 https://example.com$request_uri;
}
# HTTPS www aliases
server {
listen 443 ssl;
server_name www.example-one.com www.example-two.com www.example-three.com;
ssl_certificate /etc/ssl/www-example/fullchain.pem;
ssl_certificate_key /etc/ssl/www-example/privkey.pem;
return 301 https://example.com$request_uri;
}
# Canonical non-www site
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/ssl/example.com/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/privkey.pem;
root /var/www/example;
}
If the same certificate covers the aliases and canonical host, you may reference the corresponding certificate files in each TLS block. The important boundaries are the host matching and the separate destination site, not a particular certificate-file layout.
Decide what to do with unknown hosts
A request can arrive with a host that is not one of your intended domains. Nginx can designate a default_server to provide a controlled response:
server {
listen 80 default_server;
server_name _;
return 444;
}
The status code and behavior are policy choices. You could return a normal error response, serve a quarantine page, or redirect to a canonical host when that is genuinely appropriate. Treat this block as a rule for unmatched hosts; it is not a substitute for listing each www domain that must redirect. An overly broad catch-all can hide DNS mistakes or send unrelated hostnames to your site.
Choose the redirect status during rollout
Use 301 when the hostname change is permanent. Browsers, caches, crawlers, and intermediary systems can retain that result, so verify the mapping before switching from a temporary status.
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.
- 302: temporary redirect that is useful while checking routing and application behavior.
- 307: temporary redirect that preserves the request method and body semantics; it is useful when you are testing non-GET requests and do not want a method change.
- 301: permanent redirect for the settled canonical-host policy.
For ordinary page requests, a 301 is the final production choice. If you test with a temporary response, change the status deliberately after validation and account for cached 301 results from earlier tests.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Install the configuration safely
- List the source names. Write down every www hostname that should map to the canonical non-www host. Include spelling, hyphenation, and top-level domain exactly as users request them.
- Check DNS and reachability. Each source name must resolve to the Nginx server or load balancer that will issue the redirect. DNS changes are separate from Nginx configuration.
- Create the HTTP block. Add the exact
server_namelist on a port 80 listener and return the final canonical HTTPS URL with$request_uri. - Create the HTTPS block if needed. If clients can request
https://www..., install a certificate that covers every source name and add the port 443 redirect block. - Keep the destination separate. Configure the non-www HTTPS site in its own block with the normal
root,proxy_pass, application, and TLS settings. - Validate syntax. Run
nginx -t. Do not reload if Nginx reports a syntax error, an unknown directive, a missing include, or an unreadable certificate file. - Reload without stopping the service. After a successful test, reload Nginx using the service manager used by your system, for example
sudo systemctl reload nginx. - Test every path class. Check each source hostname over HTTP and, where enabled, HTTPS. Test the root path, a deep path, and a URL containing a query string.
Verify the response and diagnose failures
Use a client that displays response headers, such as:
curl -I http://www.example-one.com/
curl -I 'http://www.example-two.com/docs/setup?lang=en'
curl -I https://www.example-three.com/products/item-7
For each request, inspect the status and Location header. A correct result is a redirect to https://example.com with the original path and arguments intact. Follow redirects separately when you want to inspect the final response:
curl -IL 'http://www.example-two.com/docs/setup?lang=en'
The request serves the application instead of redirecting
- Confirm the hostname appears in the intended
server_namelist, with no typo. - Check that another server block is not the more specific or earlier match for that listener.
- Run
nginx -Tto inspect the fully expanded configuration and verify that the file you edited is included. - Reload Nginx after a successful
nginx -t; editing a file alone does not change the running workers.
HTTP redirects but HTTPS fails before a 301
- Verify that DNS for the HTTPS www hostname reaches this Nginx instance.
- Check the certificate’s names and validity period. TLS negotiation occurs before Nginx can evaluate the HTTP request and emit a redirect.
- Confirm that the HTTPS block listens on port 443 and contains the source hostname.
- Inspect firewall, load-balancer, or CDN TLS termination settings if Nginx is not the public TLS endpoint.
The path or query string disappears
Ensure the target is exactly https://example.com$request_uri. A hard-coded destination such as https://example.com/ intentionally discards the requested path; an incorrectly constructed rewrite can also alter arguments.
There are two or more redirects
Use the Location header from each response to identify the extra policy. A common sequence is HTTP www to HTTPS www, followed by HTTPS www to HTTPS non-www. If one-hop canonicalization is preferred, have the port 80 source block point directly to https://example.com$request_uri, while retaining the HTTPS source block for clients that start with TLS.
Operational and SEO considerations
Canonical-host redirects should be consistent across all aliases. Internal links, XML sitemaps, feeds, canonical tags, and application-generated URLs should use the non-www HTTPS host so visitors and crawlers do not repeatedly encounter redirects. Keep old paths intact with $request_uri unless a separate application-level migration requires a different mapping.
Monitor access logs after deployment for unexpected hostnames, redirect loops, certificate errors, and spikes in 4xx or 5xx responses. A redirect block should not proxy requests or execute application code; doing so adds work and creates more failure points than a direct return.
Quick Recap
Configuration checklist
- Every intended www hostname is explicitly listed, or a deliberately scoped wildcard/regex is documented.
- The redirect uses
return 301 https://example.com$request_uri;after validation. - The canonical non-www HTTPS host has its own server block and valid certificate.
- HTTPS source names have certificate coverage before the TLS redirect is expected to work.
- An optional
default_serverpolicy is kept separate from named-host redirects. nginx -tsucceeds before reload.- HTTP, HTTPS, root, deep-path, and query-string requests have been checked for every source hostname.
- The
Locationheader points to one canonical host without an unintended loop.
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.

