Из-за периодической блокировки нашего сайта РКН сервисами, просим воспользоваться резервным адресом:
Загрузить через dTub.ru Загрузить через ClipSaver.ruУ нас вы можете посмотреть бесплатно Redirecting non-www to www with Nginx или скачать в максимальном доступном качестве, которое было загружено на ютуб. Для скачивания выберите вариант из формы ниже:
Роботам не доступно скачивание файлов. Если вы считаете что это ошибочное сообщение - попробуйте зайти на сайт через браузер google chrome или mozilla firefox. Если сообщение не исчезает - напишите о проблеме в обратную связь. Спасибо.
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса savevideohd.ru
Learn how to redirect only `non-www` domains to `www` in Nginx while keeping all subdomains intact. This guide provides a clear solution for your Nginx configuration issues. --- This video is based on the question https://stackoverflow.com/q/75350506/ asked by the user 'Jasom Dotnet' ( https://stackoverflow.com/u/2195238/ ) and on the answer https://stackoverflow.com/a/75351144/ provided by the user 'Aleksey Vaganov' ( https://stackoverflow.com/u/12171038/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Nginx - redir only non-www to www, leave other subdomains intact (ignore subdomains) Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Redirecting Non-WWW to WWW with NGINX: A Comprehensive Guide When setting up a website, one common question webmasters encounter is: How do you redirect non-www versions of your website to the www version while still ignoring all subdomains? For many, this can be a frustrating hurdle, but with the right Nginx configuration, it can be accomplished quite efficiently. Understanding the Problem In the context of Nginx, the goal is to ensure that: example.com redirects to https://www.example.com Any subdomain like es.example.com remains untouched and retains its original format The redirect should work for both HTTP and HTTPS protocols It’s essential for SEO purposes and can impact your website's performance and user experience. However, achieving this clean redirect setup can be tricky if not configured correctly. Why Your Original Configuration Didn't Work In your initial configuration, two attempts were made to handle the redirects, but both faced issues: Redirecting everything to www: Using return 301 https://www.$host$request_uri; redirected all subdomains to their www equivalents (i.e., https://de.example.com became https://www.de.example.com). Blocking the subdomains: The second server block did not correctly handle requests properly, leading to confusion in response and routing for your main site. This often arises from the server_name directive and how Nginx parses redirects. To achieve the desired functionality, you'll need a careful setup in your server blocks. The Solution: Updated Nginx Configuration To redirect only the non-www version to its www counterpart while keeping subdomains intact, follow the configuration below: [[See Video to Reveal this Text or Code Snippet]] Breakdown of the Configuration First server block: Listens for HTTP requests (both example.com and www.example.com). It redirects all requests from example.com to https://www.example.com using a 301 redirect. Second server block: Specifically targets only non-www domains using a regex pattern. This will help redirect any non-www request without affecting existing subdomains (such as de.example.com, which will still work as intended). Third server block: Handles HTTPS traffic for the example.com domain specifically. It redirects to HTTPS with the www prefix. Fourth server block: This configuration allows all subdomains (like es.example.com) to remain functional without redirection to the www version. Conclusion Configuring Nginx to redirect only non-www domains to www can be crucial for maintaining a clean and efficient website without disrupting your subdomains. The provided structured configuration not only meets this need but also adheres to best practices for redirecting user traffic. Implementing these changes should resolve any issues you’ve been facing. By focusing on the right server_name directives and ensuring that your server blocks are correctly defined, you can avoid common pitfalls of misdirected traffic. Feel free to adapt the configuration as needed, and happy configuring!