{"id":2411,"date":"2020-11-26T04:59:37","date_gmt":"2020-11-26T04:59:37","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=2411"},"modified":"2025-08-28T05:07:26","modified_gmt":"2025-08-28T05:07:26","slug":"how-to-remove-www-from-domain-url-in-nginx","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/","title":{"rendered":"How To Remove WWW from Domain URL in NGINX"},"content":{"rendered":"\n<p>Generally, websites are accessible via their www as well as non-www URLs. But web administrators may need to redirect www to non-www URL to remove www from domain URL. This is useful in SEO as it helps tell search engines to treat www and non-www URLs on your website as one, and avoids any penalty. It also helps users remember the home page URLs quickly. In this article we will look at how to remove WWW from domain URL in NGINX.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#Why_Remove_WWW_from_Domain_URL\" >Why Remove WWW from Domain URL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#How_To_Remove_WWW_from_Domain_URL_in_NGINX\" >How To Remove WWW from Domain URL in NGINX<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#1_Backup_NGINX_Configuration_File\" >1. Backup NGINX Configuration File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#2_Open_NGINX_configuration_file\" >2. Open NGINX configuration file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#3_Redirect_WWW_to_Non-WWW\" >3. Redirect WWW to Non-WWW<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#4_Restart_NGINX_Server\" >4. Restart NGINX Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#5_Update_Canonical_Page_Tag_Optional\" >5. Update Canonical Page Tag (Optional)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Remove_WWW_from_Domain_URL\"><\/span>Why Remove WWW from Domain URL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We all know that Google penalizes duplicate content on a website. When a web page is accessible via both its www as well as non-www URL then search engines may see it as a duplicate content and push down that page&#8217;s ranking in search results. Also, it is difficult for users to remember whether your domain and its web pages contains www or not. So it is advisable to maintain only a single version of your web pages &#8211; either www or non-www one. Most websites these days drop www from its URLs and redirect all www pages to their non-www pages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_To_Remove_WWW_from_Domain_URL_in_NGINX\"><\/span>How To Remove WWW from Domain URL in NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the steps to remove WWW from domain URL in NGINX.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Backup_NGINX_Configuration_File\"><\/span>1. Backup NGINX Configuration File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Since we need to update NGINX configuration file, it is better to do its backup before you edit it. Open terminal and run the following command for this purpose.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo cp \/etc\/nginx\/nginx.conf \/etc\/nginx\/backup-nginx.conf<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Open_NGINX_configuration_file\"><\/span>2. Open NGINX configuration file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Open terminal and run the following command to open NGINX server configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi \/etc\/nginx\/nginx.conf<\/pre>\n\n\n\n<p>If you have configured separate virtual hosts for your website (e.g <em>www.example.com<\/em>), such as \/etc\/nginx\/sites-enabled\/website.conf then open its configuration with the following command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi&nbsp;\/etc\/nginx\/sites-enabled\/website.conf<\/pre>\n\n\n\n<p>Alternatively, you can also open the default virtual host configuration file.<\/p>\n\n\n\n<pre id=\"block-d47a260a-a7b7-47b1-8b8d-d4e8e0c49519\" class=\"wp-block-preformatted\">$ sudo vi&nbsp;\/etc\/nginx\/sites-enabled\/default<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Redirect_WWW_to_Non-WWW\"><\/span>3. Redirect WWW to Non-WWW<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You will need to create two server blocks in <a href=\"https:\/\/www.nginx.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">NGINX<\/a> configuration &#8211; one for www and another for non-www. <\/p>\n\n\n\n<p>In server block for www, we will redirect all URLs to non-www server block.<\/p>\n\n\n\n<p>Here is the full configuration for it. Replace <em>example.com<\/em> with your domain name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">server {\n  server_name www.example.com;\n  return 301 $scheme:\/\/example.com$request_uri;\n}\nserver {\n  server_name example.com;\n  ...\n}<\/pre>\n\n\n\n<p>The first server listens to URLs starting with <em>www.example.com<\/em> and redirects them to URLs starting with <em>example.com<\/em>, which is handled by the second server. The &#8216;return 301&#8217; directive does a permanent redirection. $scheme is the URL protocol (HTTP or HTTPS). $request_uri contains the URL stub in original request. Both the URL scheme and request_uri are retained in the redirected request. This is similar to <a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/\">redirecting HTTP to HTTPS pages<\/a>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Restart_NGINX_Server\"><\/span>4. Restart NGINX Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Run the following command to check syntax of your updated config file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo nginx -t<\/pre>\n\n\n\n<p>If there are no errors, run the following command to restart NGINX server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo service nginx reload #debian\/ubuntu\n$ systemctl restart nginx #redhat\/centos<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Update_Canonical_Page_Tag_Optional\"><\/span>5. Update Canonical Page Tag (Optional)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Most web pages contain canonical tag to tell search engines about the original URL of those pages. In case there are multiple URLs on your website, with the same content, then search engines will use the canonical link&#8217;s URL as the original page. Search engines display this canonical URL in search results so it is important. This is common in ecommerce sites where each page can be accessed via multiple URLs. <\/p>\n\n\n\n<p>So after you have redirected a web page from its www URL to its non-www one, it is also important to update the canonical URL tag, if any, in the page&#8217;s code. For example, if your canonical tag contains www URL then you need to update it to non-www URL. Let us say you have the following canonical tag on your home page.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;link <strong>rel=\"canonical\"<\/strong> href=\"https:\/\/<strong>www.example.com<\/strong>\" \/&gt;<\/pre>\n\n\n\n<p>You will need to update it to the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;link <strong>rel=\"canonical\"<\/strong> href=\"https:\/\/<strong>example.com<\/strong>\" \/&gt;<\/pre>\n\n\n\n<p>If you do not make the above change, then search engines will continue to use the www version of URL as the original URL and show it search results. Alternatively, you can completely remove this tag from your web page. Based on the result of redirection, search engines will automatically deduce the original URL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Hopefully, this article will help you redirect WWW to Non-WWW URLs in NGINX. Basically, you need to open NGINX virtual host or config file and create two server blocks &#8211; one for handling www requests and the other for handling non-www requests. The server handling www requests redirects all received requests to the 2nd server. We have used return statement for URL redirection. NGINX provides several ways such as using rewrite directive for redirecting URLs. You can use any of them depending on your requirement. After setting up redirection, remember to update the canonical tag in your web pages so that search engines clearly understand which is the original URL &#8211; www or non-www one.<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;makes it easy to visualize data, and monitor them in real-time dashboards.&nbsp;<a href=\"https:\/\/ubiq.co\/accounts\/register\">Try Ubiq<\/a>&nbsp;for free.<\/p>\n\n\n\n<p>Also read : <br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/\">How to Redirect WWW to Non-WWW URLs<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/\">How to Configure Basic Authentication in NGINX<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/rewrite-vs-redirect-nginx\/\">Rewrite vs Redirect in NGINX<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to redirect www URL to non-www URL. Here is how to remove www from domain URL in NGINX. <\/p>\n","protected":false},"author":1,"featured_media":2420,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[238],"class_list":["post-2411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","tag-remove-www"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Remove WWW from Domain URL in NGINX - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to redirect www URL to non-www URL. Here is how to remove www from domain URL in NGINX.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Remove WWW from Domain URL in NGINX - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to redirect www URL to non-www URL. Here is how to remove www from domain URL in NGINX.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-26T04:59:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-28T05:07:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/nginx-redirect-www-to-non-www.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1429\" \/>\n\t<meta property=\"og:image:height\" content=\"750\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How To Remove WWW from Domain URL in NGINX\",\"datePublished\":\"2020-11-26T04:59:37+00:00\",\"dateModified\":\"2025-08-28T05:07:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/\"},\"wordCount\":822,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1\",\"keywords\":[\"remove www\"],\"articleSection\":[\"Nginx\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/\",\"name\":\"How To Remove WWW from Domain URL in NGINX - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1\",\"datePublished\":\"2020-11-26T04:59:37+00:00\",\"dateModified\":\"2025-08-28T05:07:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to redirect www URL to non-www URL. Here is how to remove www from domain URL in NGINX.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1\",\"width\":1429,\"height\":750,\"caption\":\"remove www from domain URL\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-remove-www-from-domain-url-in-nginx\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Remove WWW from Domain URL in NGINX\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Remove WWW from Domain URL in NGINX - Ubiq BI","description":"Sometimes you may need to redirect www URL to non-www URL. Here is how to remove www from domain URL in NGINX.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/","og_locale":"en_US","og_type":"article","og_title":"How To Remove WWW from Domain URL in NGINX - Ubiq BI","og_description":"Sometimes you may need to redirect www URL to non-www URL. Here is how to remove www from domain URL in NGINX.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-11-26T04:59:37+00:00","article_modified_time":"2025-08-28T05:07:26+00:00","og_image":[{"width":1429,"height":750,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/nginx-redirect-www-to-non-www.png","type":"image\/png"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How To Remove WWW from Domain URL in NGINX","datePublished":"2020-11-26T04:59:37+00:00","dateModified":"2025-08-28T05:07:26+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/"},"wordCount":822,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1","keywords":["remove www"],"articleSection":["Nginx"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/","name":"How To Remove WWW from Domain URL in NGINX - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1","datePublished":"2020-11-26T04:59:37+00:00","dateModified":"2025-08-28T05:07:26+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to redirect www URL to non-www URL. Here is how to remove www from domain URL in NGINX.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1","width":1429,"height":750,"caption":"remove www from domain URL"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-remove-www-from-domain-url-in-nginx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How To Remove WWW from Domain URL in NGINX"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/nginx-redirect-www-to-non-www.png?fit=1429%2C750&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-CT","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=2411"}],"version-history":[{"count":23,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2411\/revisions"}],"predecessor-version":[{"id":9320,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2411\/revisions\/9320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/2420"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=2411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=2411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=2411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}