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
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
To redirect blog.example.com to example.com/blog and retain every incoming path and query string, create a dedicated Nginx server block for the subdomain and return the destination URL with $request_uri:
server {
listen 80;
server_name blog.example.com;
return 301 https://example.com/blog$request_uri;
}
A request for http://blog.example.com/article?id=42 will receive a 301 response whose Location header is https://example.com/blog/article?id=42. Use a temporary 302 while you test, then change it to 301 only after the destination, assets, canonical URLs and redirects work correctly.
What this configuration does
This is a client-side redirect. Nginx responds to the subdomain request with a 3xx status, and the browser makes a new request to the main hostname and subfolder. The address bar therefore changes from blog.example.com/... to example.com/blog/....
The separate virtual-server block is important. Nginx selects a server according to the request hostname and listener; putting the rule in the wrong block can send the request to another site or to the default server. The exact subdomain must appear in server_name.
#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: 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.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
How $request_uri preserves the request
$request_uri contains the original URI, including its path and query string. With the example rule:
/becomes/blog/./news/launchbecomes/blog/news/launch./search?q=nginxbecomes/blog/search?q=nginx.
Do not append only $uri when query parameters must survive; $uri does not carry the original query string in the same way. Also avoid adding a second question mark to the destination. The query component already travels inside $request_uri.
Before you change Nginx
Point DNS at this Nginx server
Create an A record for the subdomain if it uses IPv4, an AAAA record if it uses IPv6, or an appropriate CNAME arrangement. The record must ultimately reach the Nginx host that contains the redirect block. DNS propagation and any provider-level proxying can affect when your test reaches the new server.
Check hostname matching
Use the fully qualified hostname in server_name, for example blog.example.com. Nginx can route unmatched names to a default_server, so a typo or missing DNS record may appear to work while actually testing a different virtual host.
Plan HTTP and HTTPS separately
If visitors use HTTPS, the subdomain certificate must cover blog.example.com. Nginx must also have a TLS listener for that name. A certificate for example.com alone does not automatically cover every subdomain unless the certificate explicitly includes it, such as through a suitable wildcard name.
Permanent HTTP redirect
For a straightforward permanent move, use return at server level:
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 →server {
listen 80;
server_name blog.example.com;
return 301 https://example.com/blog$request_uri;
}
The return directive immediately ends processing and sends the supplied status and URL. It is clearer and less error-prone than conditional rewrite logic for a hostname-wide redirect. A 301 tells clients and search engines that the move is permanent.
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
Use a 302 during rollout
Replace 301 with 302 while validating:
server {
listen 80;
server_name blog.example.com;
return 302 https://example.com/blog$request_uri;
}
Browsers, operating systems and intermediary caches can retain a 301. If you discover an error after publishing one, changing the configuration may not change an already cached response for every tester. A temporary redirect lets you correct the destination without that permanent-cache behavior.
Nginx also supports other redirect statuses in the return directive, including 303 and 307. Choose those only when their method-handling semantics are intentional; ordinary browser URL moves generally use 301 or 302.
Redirect HTTP and HTTPS correctly
A common deployment uses one HTTP block to upgrade the connection and a separate TLS block to perform the subdomain-to-subfolder redirect.
Recommended Free Tools
server {
listen 80;
server_name blog.example.com;
return 301 https://blog.example.com$request_uri;
}
server {
listen 443 ssl;
server_name blog.example.com;
ssl_certificate /path/to/blog.example.com/fullchain.pem;
ssl_certificate_key /path/to/blog.example.com/privkey.pem;
return 301 https://example.com/blog$request_uri;
}
The certificate paths above are examples of configuration locations, not universal filesystem paths; use the paths installed by your certificate process. The first block ensures an HTTP request reaches HTTPS on the same subdomain. The second block then moves the request to the final hostname and subfolder.
When the destination also needs HTTPS
The destination URL in the final return should be the canonical scheme used by the main site. If the destination site itself redirects HTTP to HTTPS, sending users directly to its HTTPS URL avoids an unnecessary extra hop.
Certificate and DNS failure symptoms
- A browser certificate warning before a redirect usually means the subdomain certificate is missing, expired, or does not contain the requested name. The browser must complete TLS before it can accept an HTTPS redirect.
- An unexpected site or connection failure often indicates that DNS points elsewhere or that the TLS request is being handled by a different virtual server.
- A redirect loop can occur when another proxy or application rewrites the scheme differently from Nginx. Inspect each response’s
Locationheader to identify the repeating hop.
Preserve or discard the original path deliberately
Keep the path and query string
Use $request_uri when the subfolder mirrors the old subdomain’s URL structure:
return 301 https://example.com/blog$request_uri;
This maps /category/linux?page=2 to /blog/category/linux?page=2. It is the usual choice for a whole-subdomain migration.
Free tools Windows power users keep installed
One-click scans. No signup required.
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.
Send every request to one fixed URL
If all old URLs should land on one page, omit $request_uri:
return 301 https://example.com/blog;
This intentionally discards both the incoming path and query string. Use it only when the destination application has no one-to-one URL mapping and you have decided that losing those values is acceptable.
Map only selected paths
For a small number of exceptions, use separate, more-specific locations or server rules before a general redirect. Document each exception so a later catch-all rule does not silently override it. A hostname-wide move is usually easier to maintain when the mapping is expressed as a simple server-level return.
Redirect versus internal rewrite
A redirect changes what the browser displays. An internal rewrite changes the URI Nginx processes while keeping the original hostname visible to the client.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
| Requirement | Approach | Visible browser URL | Typical use |
|---|---|---|---|
| Move visitors to the main hostname | return 301 ... |
example.com/blog/... |
Public hostname migration or canonicalization |
| Keep the subdomain in the address bar | Internal rewrite or proxying | blog.example.com/... |
Compatibility front end or application-specific routing |
| Test without permanent caching | return 302 ... |
Temporary destination URL | Rollout and troubleshooting |
Internal rewrite example
The rewrite module can apply an internal URI change, or it can issue a redirect when given a redirect or permanent flag. An internal rule is appropriate only when the subdomain should remain visible; it does not provide the canonical-host move shown in the main recipe.
Because rewrite behavior depends on the location, replacement URI and processing phase, inspect the resulting URI and test query-string handling rather than assuming it matches a server-level return. For a simple hostname redirect, a dedicated server block avoids that complexity.
Keeping the subdomain while proxying to a subfolder
If an application must receive a /blog/ prefix but users must continue seeing blog.example.com, proxy the request instead of redirecting the client:
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.
server {
listen 80;
server_name blog.example.com;
location / {
proxy_pass http://app_backend/blog/;
}
}
Here the browser stays on the subdomain and Nginx forwards the request to the upstream application. The trailing URI in proxy_pass is significant: when proxy_pass includes a URI, Nginx replaces the part of the request URI that matched the location with that URI. Thus a request for /article under location / is sent with the configured /blog/ prefix.
If proxy_pass has no URI, Nginx forwards the full original request URI instead. Compare these deliberately:
| Configuration | Request to /article |
Resulting upstream path |
|---|---|---|
proxy_pass http://app_backend/blog/; |
/article |
Prefix replacement produces a path under /blog/ |
proxy_pass http://app_backend; |
/article |
The full original path /article |
Exact normalization can also be affected by the location pattern and slash placement. Test both the bare path and nested paths after every change.
Watch upstream-generated redirects
An application may return a Location header containing its internal hostname or a path without the required prefix. The browser follows that header, potentially exposing the upstream, dropping /blog/, or entering a loop. Check response headers and configure the application or proxy handling so generated absolute URLs, cookies and canonical links match the public URL design.
Nginx Ingress Controller variant
On Kubernetes, you normally do not edit the generated Nginx server block directly. URI rewriting is configured on the Ingress resource with annotations supported by the controller version in use.
Crashes, 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 minutePC 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 & 11The official controller reference documents nginx.org/rewrite-target, including regular-expression capture groups when path-regex is enabled, and also documents nginx.org/rewrites. These annotation approaches are mutually exclusive; select the one that matches the controller and routing behavior you need.
Verify the rendered Ingress configuration and test the external hostname after applying it. Annotation names and supported options are controller-specific, so a manifest copied from a different controller or version may be ignored or produce different routing.
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.
Validate the redirect safely
- Parse the configuration. Run
nginx -t. Do not reload until Nginx reports that the syntax test succeeded. - Reload Nginx. Use your service manager’s reload operation so existing connections can finish while the new configuration is adopted.
- Check the bare hostname. Request
http://blog.example.com/and confirm the expected status and destination. - Check a nested path and query. Test a URL such as
/article/intro?ref=testand verify that the result is/blog/article/intro?ref=teston the target host. - Inspect headers. Use
curl -Ior another HTTP client and read the status andLocationheader. A redirect test should not rely only on what a browser displays after following several hops. - Test both schemes. If TLS is configured, test HTTP and HTTPS independently, including certificate validation and the intended number of redirects.
- Load the final page. Confirm that HTML, stylesheets, scripts, images and API calls resolve under the destination site. Check canonical tags, cookie domains and application-generated links for references to the old hostname.
Useful header checks
curl -I http://blog.example.com/article/intro?ref=test
curl -I https://blog.example.com/article/intro?ref=test
These commands request headers only. If a client follows redirects by default in your environment, disable redirect following when you need to inspect the first response; then request the reported destination separately.
Troubleshooting common failures
The request reaches the wrong site
Confirm DNS, the listening address and the exact server_name. Check whether another server is marked default_server and whether the request’s Host header is the name you intended. Testing by IP without supplying the correct Host header can select a different virtual server.
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 path is duplicated
A destination such as /blog/blog/article usually means the source path already includes the prefix or another layer adds it. Compare the incoming request, the literal destination prefix and the value of $request_uri. Remove one of the duplicated path components rather than adding another rewrite.
The query string disappears
Use $request_uri in the redirect and check that an intermediate proxy or application is not issuing a second redirect without the query. A fixed destination such as https://example.com/blog intentionally drops the original values.
A 301 appears unchanged after editing
Clear the browser’s cached redirect or test with a fresh client and inspect the response using curl -I. During future changes, use 302 until the complete chain is confirmed.
There is a redirect loop
Capture every hop and compare schemes, hosts and paths. Typical causes include an HTTP-to-HTTPS rule that points back to HTTP, a proxy that does not communicate the original scheme, or an upstream application redirecting to the old subdomain. Fix the first response that points in the wrong direction.
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 glitchesThe proxy sends the wrong upstream path
Review whether proxy_pass includes a URI and whether its trailing slash matches the location. A URI-bearing value performs location-prefix replacement; a value without a URI preserves the original request path.
Choosing the right method
| Goal | Recommended configuration | Reason |
|---|---|---|
| Make the main site the public canonical hostname | Dedicated subdomain server block with return 301 https://example.com/blog$request_uri |
Simple, explicit client redirect that preserves path and query |
| Try the move before committing | Same rule with 302 |
Avoids premature permanent caching |
| Keep the old hostname visible | Internal rewrite | The browser does not receive a new public URL |
| Present a subfolder to an application behind the subdomain | proxy_pass with deliberate URI and slash handling |
Nginx controls the upstream path while the client remains on the subdomain |
| Configure Kubernetes-managed Nginx | Ingress rewrite annotations supported by the installed controller | The controller generates the server configuration |
For the usual “move this subdomain under that site’s folder” requirement, the dedicated server block and return directive are the least surprising solution. Decide first whether the browser should change hosts; that single choice determines whether you need a redirect or internal routing.
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.

