Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesiTechGuides 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
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
Use one canonical hostname—usually https://example.com—and permanently redirect every www request to it. In Nginx, put a return 301 in a dedicated www server block. In Apache, put a permanent Redirect in the www virtual host. Configure TLS for www as well, because an HTTPS connection must complete its certificate handshake before the server can issue the redirect.
What the redirect should accomplish
A canonical-host redirect makes one URL the authoritative address for the site. A request for http://www.example.com/, http://www.example.com/docs/start, or https://www.example.com/search?q=nginx should end at the corresponding HTTPS URL on the bare domain:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
https://example.com/https://example.com/docs/starthttps://example.com/search?q=nginx
Use an HTTP 301 (permanent) response and preserve the original request URI. This keeps deep links, file paths, and query strings usable while telling browsers and crawlers that the hostname change is permanent. A single canonical hostname also avoids maintaining separate cache and search-engine versions of the same site.
Plan the hostnames, ports, and certificates first
Replace example.com in every example with your real domain. Decide that the bare domain is canonical before editing configuration. The redirect design normally has four entry points:
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
| Request | Expected action | Where it is handled |
|---|---|---|
http://www.example.com |
301 to https://example.com, preserving path and query |
Port 80 www server or virtual host |
http://example.com |
301 to https://example.com when HTTPS is mandatory |
Port 80 canonical server or virtual host |
https://www.example.com |
301 to https://example.com, preserving path and query |
Port 443 www TLS server or virtual host |
https://example.com |
Serve the application without redirecting back to www |
Port 443 canonical server or virtual host |
The HTTPS www endpoint must have a certificate whose names cover www.example.com (or a suitable wildcard/SAN certificate). The browser performs TLS before it can receive an HTTP 301, so a certificate that covers only the bare domain cannot reliably redirect HTTPS www traffic.
Make sure DNS for both names reaches the server or proxy that owns these configurations. Back up the active configuration and identify the normal syntax-check, reload, and rollback procedures for your deployment.
Recommended Free Tools
Redirect www to non-www in Nginx
Use a separate HTTP redirect server
Nginx selects a server block from the listening address, port, and server_name. Define the alternate hostname explicitly and keep its job limited to redirecting:
server {
listen 80;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
$request_uri contains the original path and arguments, so /docs/start?lang=en remains /docs/start?lang=en after the host and scheme change. Nginx’s return directive is the simple mechanism for this case and avoids unnecessary rewrite processing.
Redirect the bare HTTP hostname when HTTPS is required
If the entire site must use HTTPS, give the canonical HTTP name its own block:
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
If your application intentionally serves HTTP on the bare domain, this block can instead contain the site’s normal root, proxy, and location rules. Do not put the www redirect inside that application block; keeping the alternate hostname separate makes the routing unambiguous.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
Terminate TLS and redirect HTTPS www
Create a certificate-bearing port 443 block for www. It terminates TLS and then returns the same permanent redirect:
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
return 301 https://example.com$request_uri;
}
The certificate paths above are an example layout; use the paths installed by your certificate-management process. The certificate must include www.example.com, even though the server immediately redirects that name.
Serve the canonical HTTPS site
The bare-domain TLS block is the only block in this design that serves the application:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
root /var/www/example;
# application-specific location/proxy rules go here
}
For a reverse-proxied application, put the existing location and proxy_pass rules in this canonical block. Do not duplicate the application rules in the redirect block.
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 →Why not combine the Nginx conditions with a broad if?
For this hostname-only case, a dedicated www server is clearer and safer than a combined conditional rule. Nginx documentation describes a separate server as the right structure for converting this kind of rewrite. It also keeps the canonical block free of a rule that could accidentally redirect canonical requests back to themselves.
Redirect www to non-www in Apache
Preferred method: mod_alias in virtual hosts
Apache’s simplest hostname redirect uses Redirect permanent in the virtual host for the non-canonical name. Create an HTTP virtual host for www and, when HTTPS is enforced, one for the canonical HTTP name:
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
With a Redirect whose source is /, Apache appends the path matched after that prefix to the target. A request for /docs/start therefore becomes https://example.com/docs/start. The original query string is retained when Apache performs this redirect.
Configure the HTTPS virtual hosts
The www TLS virtual host must load a certificate covering www.example.com and issue the redirect:
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 matchPC 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 & 11<VirtualHost *:443>
ServerName www.example.com
SSLEngine on
SSLCertificateFile /path/to/fullchain.pem
SSLCertificateKeyFile /path/to/privkey.pem
Redirect permanent / https://example.com/
</VirtualHost>
Use the certificate-file directives and paths required by your Apache build and certificate provider. The canonical TLS virtual host serves the application:
<VirtualHost *:443>
ServerName example.com
SSLEngine on
SSLCertificateFile /path/to/fullchain.pem
SSLCertificateKeyFile /path/to/privkey.pem
DocumentRoot /var/www/example
# application-specific Directory, proxy, and other rules go here
</VirtualHost>
Apache documentation recommends this virtual-host Redirect approach for a straightforward canonical-host change rather than using mod_rewrite. Keep the redirect in the non-canonical virtual host so the canonical host never evaluates it.
Use mod_rewrite only when conditional logic is needed
If the redirect depends on a condition that Redirect cannot express, use a rewrite rule in the www virtual host or an appropriately scoped document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
RewriteCondlimits the rule to the alternate hostname, case-insensitively.%{REQUEST_URI}carries the requested path into the destination.R=301makes the redirect permanent.Lstops further rewrite processing for that request.NEprevents Apache from unnecessarily escaping characters already present in the redirect target.
Do not activate this rule in the canonical host without the hostname condition. A rule that runs on both names can create a loop or repeatedly rewrite an already-canonical request. Apache normally retains the original query string when the substitution does not introduce a new query component.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
Prevent HTTPS and hostname redirect loops
A loop occurs when each host redirects to the other, or when the canonical HTTPS virtual host still contains a rule intended only for www. The safe flow is one-way:
- The client requests a URL.
- The appropriate HTTP or HTTPS endpoint identifies whether the host is
www. - A
wwwrequest receives one 301 to the same path onhttps://example.com. - The canonical HTTPS host serves the response and does not redirect back.
Do not rely on an HTTP redirect to fix an invalid HTTPS certificate: TLS negotiation happens first. Install a certificate that covers the www name on the port 443 redirect endpoint. Also check that a load balancer or reverse proxy in front of Nginx or Apache is not adding a second, conflicting host rule.
The desired result for http://www.example.com/docs/start?lang=en is one redirect directly to https://example.com/docs/start?lang=en, not a chain through HTTP bare, HTTPS www, and finally HTTPS bare. Fewer hops make diagnostics and cache behavior more predictable.
Validate the configuration safely
1. Check syntax before reloading
Run the normal configuration test for the server that is actually handling traffic. For Nginx, the standard check is:
sudo nginx -t
For Apache, use the configuration test command provided by your installation, commonly:
sudo apachectl configtest
Resolve every syntax error, duplicate directive, missing certificate file, and unknown module before reloading.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
2. Reload gracefully
Use your deployment’s standard service manager or control command to reload the validated configuration. A graceful reload lets existing connections finish while new connections use the new virtual hosts. Keep the previous configuration available so you can restore it if the listener or certificate setup is wrong.
3. Test redirects with headers only
Use curl without following redirects first, so you can inspect the status and Location header:
curl -I http://www.example.com/
curl -I http://www.example.com/docs/start?lang=en
curl -I https://www.example.com/
curl -I http://example.com/docs/start?lang=en
Each www request should return 301 and a Location beginning with https://example.com/. The deep path and query string should be present in the location value. The HTTPS www request must complete its certificate handshake before returning that header.
4. Confirm the canonical host serves content
curl -I https://example.com/
curl -I https://example.com/docs/start?lang=en
These requests should return the application’s normal response—such as 200, or an application-specific status—not a redirect back to www. To see the complete chain during troubleshooting, use curl -IL, but verify that production traffic normally needs only the one canonicalization redirect.
5. Test unmatched host headers
Send a request with an unknown Host value or inspect the default server behavior. Nginx can route unmatched names to a default server; do not let that fallback unintentionally expose the application or redirect arbitrary hostnames to it. Configure a deliberate default response or a separate default server according to your security policy.
Common failures and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Browser reports a certificate error before any 301 | The port 443 www endpoint lacks a certificate covering www.example.com. |
Install a matching certificate and ensure the www TLS server or virtual host selects it. |
www redirects to itself |
The destination still contains www, or proxy headers cause the application to think the canonical host is different. |
Set the destination explicitly to https://example.com$request_uri in Nginx or https://example.com/ in Apache, then inspect upstream host handling. |
Canonical host redirects back to www |
The redirect rule is active in the canonical server or virtual host. | Move the rule to the dedicated www endpoint and leave the canonical HTTPS block serving content. |
| Deep links lose their path | The target was hard-coded as the domain root, or the Apache redirect is scoped incorrectly. | Use Nginx $request_uri; with Apache Redirect permanent / https://example.com/, verify the source prefix and test a nested path. |
| Query parameters disappear | A rewrite substitution replaced the query string or application middleware rebuilt the URL. | Use the original request URI in Nginx and avoid adding an unintended ? in Apache rewrite substitutions; test a URL containing ?key=value. |
Requests work on HTTP but fail on HTTPS www |
No matching 443 server or virtual host is enabled, or TLS is terminated elsewhere. | Configure the certificate-bearing 443 www endpoint at the layer that receives the connection. |
| Unexpected content appears for an unrelated hostname | An unmatched name is falling into the application’s default server. | Define deliberate default-server behavior and test an unknown Host separately. |
| Two or more 301 responses occur | Separate layers are redirecting HTTP, www, and HTTPS one at a time. |
Make the first www response point directly to the final HTTPS bare URL and remove overlapping rules. |
Nginx and Apache approaches compared
| Concern | Nginx | Apache |
|---|---|---|
| Configuration location | Separate server blocks selected by server_name. |
Separate virtual hosts selected by ServerName. |
| Simple redirect directive | return 301 https://example.com$request_uri; |
Redirect permanent / https://example.com/ |
| Conditional rules | Possible with rewrite features, but unnecessary for a hostname-only redirect. | mod_rewrite supports conditions such as an exact HTTP_HOST match. |
| Path and query preservation | $request_uri explicitly carries the path and arguments. |
Redirect appends the matched path; the original query string is retained. A rewrite substitution should avoid unintentionally replacing it. |
| TLS requirement | Port 443 www block must terminate TLS with a certificate covering www. |
Port 443 www virtual host must do the same before Redirect runs. |
| Loop prevention | Keep the redirect block separate from the canonical application block. | Scope Redirect or RewriteCond to the non-canonical virtual host. |
| Operational validation | Run nginx -t, reload, then test with curl -I. |
Run apachectl configtest (or the installation’s equivalent), reload, then test with curl -I. |
Deployment checklist
- Choose exactly one canonical hostname and use it consistently in redirects and application settings.
- Define both
wwwand bare names explicitly on every relevant port. - Install a certificate covering
www.example.combefore testing HTTPS redirects. - Use a permanent 301 that points directly to the final HTTPS bare URL.
- Preserve the original path and query string.
- Keep the redirect endpoint separate from the canonical application endpoint.
- Check syntax before reload and retain a rollback configuration.
- Test root URLs, nested paths, query strings, both schemes, and an unknown host.
- Verify that
https://example.comserves content without redirecting towww. - Inspect the full redirect chain and remove any unnecessary intermediate hop.
How to choose between the two implementations
Use Nginx’s dedicated server blocks when Nginx terminates the connection or acts as the reverse proxy. Use Apache virtual hosts with Redirect permanent when Apache owns the HTTP and HTTPS listeners. In either server, the hostname-level redirect is deliberately small: the important operational work is selecting the correct virtual host, covering the TLS name, preserving the URI, and ensuring that the canonical host serves rather than redirects.
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.

