{"id":9633,"date":"2026-06-03T07:51:44","date_gmt":"2026-06-03T05:51:44","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=9633"},"modified":"2026-06-03T07:51:45","modified_gmt":"2026-06-03T05:51:45","slug":"how-to-redirect-a-domain-to-the-non-www-version-using-htaccess","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/","title":{"rendered":"How to Redirect a Domain to the Non-WWW Version Using .htaccess"},"content":{"rendered":"\n<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">If you want visitors to always access your website without the <strong>www<\/strong> prefix, you can configure a permanent redirect in the <code>.htaccess<\/code> file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;www.yourdomain.com<\/code><\/pre>\n\n\n\n<\/div>\n\n<div id=\"mybox-2618691070\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Early access<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Still need help?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contact our customer service team.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Message us<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">will automatically redirect to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;yourdomain.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This helps maintain a consistent URL structure and can improve SEO by preventing duplicate content issues.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom 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\"><\/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:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/#Before_You_Begin\" >Before You Begin<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/#Redirect_WWW_to_Non-WWW\" >Redirect WWW to Non-WWW<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/#How_It_Works\" >How It Works<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/#Redirect_WWW_to_Non-WWW_with_HTTPS\" >Redirect WWW to Non-WWW with HTTPS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/#Testing_the_Redirect\" >Testing the Redirect<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/#Common_Issues\" >Common Issues<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-to-redirect-a-domain-to-the-non-www-version-using-htaccess\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Before_You_Begin\"><\/span>Before You Begin<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>.htaccess<\/code> file is typically located in your website&#8217;s root directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public_html<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the file does not exist, you can create it manually.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Before editing <code>.htaccess<\/code>, create a backup of the file in case you need to restore the previous configuration.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Redirect_WWW_to_Non-WWW\"><\/span>Redirect WWW to Non-WWW<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following rules to your <code>.htaccess<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Redirect www to non-www<br><br>RewriteEngine On<br>RewriteCond %{HTTP_HOST} ^www\\.(.*)$ &#91;NC]<br>RewriteRule ^(.*)$ http:\/\/%1\/$1 &#91;R=301,L]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_It_Works\"><\/span>How It Works<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>RewriteEngine On<\/code> enables URL rewriting.<\/li>\n\n\n\n<li><code>RewriteCond %{HTTP_HOST} ^www\\.(.*)$ [NC]<\/code> checks whether the requested hostname starts with <code>www<\/code>.<\/li>\n\n\n\n<li><code>RewriteRule<\/code> redirects the visitor to the same URL without the <code>www<\/code> prefix.<\/li>\n\n\n\n<li><code>R=301<\/code> creates a permanent redirect.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Redirect_WWW_to_Non-WWW_with_HTTPS\"><\/span>Redirect WWW to Non-WWW with HTTPS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If your website uses an SSL certificate, it is recommended to redirect visitors directly to the secure HTTPS version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteEngine On<br>RewriteCond %{HTTP_HOST} ^www\\.(.*)$ &#91;NC]<br>RewriteRule ^(.*)$ https:\/\/%1\/$1 &#91;R=301,L]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;www.yourdomain.com\/page<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">becomes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;yourdomain.com\/page<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Testing_the_Redirect\"><\/span>Testing the Redirect<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After saving the <code>.htaccess<\/code> file:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your website using the WWW version.<\/li>\n\n\n\n<li>Verify that the browser automatically redirects to the non-WWW address.<\/li>\n\n\n\n<li>Check several pages and subpages to ensure the redirect works correctly throughout the website.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Common_Issues\"><\/span>Common Issues<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If the redirect does not work:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify that the <code>.htaccess<\/code> file is located in the correct directory.<\/li>\n\n\n\n<li>Check for conflicting redirect rules.<\/li>\n\n\n\n<li>Clear your browser cache before testing again.<\/li>\n\n\n\n<li>Ensure that URL rewriting is enabled on the server.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To force visitors to use the non-WWW version of your website, add the following rule to the <code>.htaccess<\/code> file located in your website&#8217;s root directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteEngine On<br>RewriteCond %{HTTP_HOST} ^www\\.(.*)$ &#91;NC]<br>RewriteRule ^(.*)$ http:\/\/%1\/$1 &#91;R=301,L]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If your website uses SSL, replace <code>http:\/\/<\/code> with <code>https:\/\/<\/code> to ensure visitors are redirected to the secure version of the site.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[125],"manual_kb_tag":[1550,2598,2599,2604,2611,4871,5089,5090,5091,5092],"class_list":["post-9633","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-websites","manual_kb_tag-https-redirect","manual_kb_tag-domain-redirect","manual_kb_tag-permanent-redirect","manual_kb_tag-url-redirect","manual_kb_tag-htaccess-redirect","manual_kb_tag-30-redirect","manual_kb_tag-redirect-to-nonwww","manual_kb_tag-remove-www-prefix","manual_kb_tag-force-nonwww","manual_kb_tag-ssl-redirect"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/9633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/9633\/revisions"}],"predecessor-version":[{"id":9634,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/9633\/revisions\/9634"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/media?parent=9633"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manualknowledgebasecat?post=9633"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb_tag?post=9633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}