{"id":9652,"date":"2026-06-03T08:08:09","date_gmt":"2026-06-03T06:08:09","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=9652"},"modified":"2026-06-03T08:08:10","modified_gmt":"2026-06-03T06:08:10","slug":"cum-sa-redirectionati-un-domeniu-catre-un-director-folosind-htaccess","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-using-htaccess\/","title":{"rendered":"Cum s\u0103 redirec\u021biona\u021bi un domeniu c\u0103tre un director utiliz\u00e2nd .htaccess"},"content":{"rendered":"<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">If you want visitors to be automatically redirected to a specific directory within your website, you can achieve this using rules in the <code>.htaccess<\/code> file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This can be useful when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Rebuilding your main website while keeping a section online.<\/li>\n\n\n\n<li>Redirecting visitors directly to an online store.<\/li>\n\n\n\n<li>Making a subdirectory the primary entry point of the website.<\/li>\n\n\n\n<li>Temporarily displaying content from a specific folder.<\/li>\n<\/ul>\n\n\n\n<\/div>\n\n<div id=\"mybox-2054402397\" 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\">Acces timpuriu<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Mai ave\u021bi nevoie de ajutor?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contacta\u021bi echipa noastr\u0103 de servicii pentru clien\u021bi.<\/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\">Trimite mesaj<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">For example, visitors accessing:<\/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\">can be automatically redirected to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;yourdomain.com\/store<\/code><\/pre>\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\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-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\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-using-htaccess\/#Redirect_the_Domain_to_a_Directory\" >Redirect the Domain to a Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-using-htaccess\/#Example\" >Example<\/a><\/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\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-using-htaccess\/#How_the_Rule_Works\" >How the Rule Works<\/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\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-using-htaccess\/#Important_Notes\" >Important Notes<\/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\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-using-htaccess\/#Troubleshooting\" >Troubleshooting<\/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\/ro\/knowledgebase\/how-to-redirect-a-domain-to-a-directory-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 should be located in your website&#8217;s root directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By default, this is:<\/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<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Redirect_the_Domain_to_a_Directory\"><\/span>Redirect the Domain to a Directory<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>RewriteEngine On<br>RewriteCond %{HTTP_HOST} ^(www\\.)?yourdomain\\.com$ &#91;NC]<br><br>RewriteCond %{REQUEST_URI} !^\/store\/<br>RewriteRule ^(.*)$ \/store\/$1 &#91;L]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yourdomain.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">with your actual domain name, and:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/store\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">with the directory to which you want visitors redirected.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Example\"><\/span>Example<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To redirect all traffic from:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;mywebsite.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;mywebsite.com\/shop<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteEngine On<br>RewriteCond %{HTTP_HOST} ^(www\\.)?mywebsite\\.com$ &#91;NC]<br><br>RewriteCond %{REQUEST_URI} !^\/shop\/<br>RewriteRule ^(.*)$ \/shop\/$1 &#91;L]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_the_Rule_Works\"><\/span>How the Rule Works<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Checks whether the request is for the specified domain.<\/li>\n\n\n\n<li>Verifies that the visitor is not already inside the target directory.<\/li>\n\n\n\n<li>Redirects all requests into the selected directory.<\/li>\n\n\n\n<li>Prevents redirect loops.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Without the second condition:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteCond %{REQUEST_URI} !^\/store\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">the website could continuously redirect itself.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Important_Notes\"><\/span>Important Notes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure the target directory already exists.<\/li>\n\n\n\n<li>Verify that the directory contains a valid website or index file.<\/li>\n\n\n\n<li>Back up your existing <code>.htaccess<\/code> file before making changes.<\/li>\n\n\n\n<li>Test the redirect after saving the file.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Troubleshooting\"><\/span>Troubleshooting<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>Confirm the <code>.htaccess<\/code> file is located in the correct directory.<\/li>\n\n\n\n<li>Check that the directory name is correct.<\/li>\n\n\n\n<li>Clear your browser cache.<\/li>\n\n\n\n<li>Verify there are no conflicting redirect rules in the file.<\/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 redirect all visitors from a domain to a specific directory, place the following rule in the <code>.htaccess<\/code> file located in your website&#8217;s <code>public_html<\/code> directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteEngine On<br>RewriteCond %{HTTP_HOST} ^(www\\.)?yourdomain\\.com$ &#91;NC]<br><br>RewriteCond %{REQUEST_URI} !^\/store\/<br>RewriteRule ^(.*)$ \/store\/$1 &#91;L]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After saving the file, visitors accessing the domain will automatically be directed to the selected directory within the website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[125],"manual_kb_tag":[2602,2612,5038,5039,5040,5041,5042,1320,1626,2598],"class_list":["post-9652","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-websites","manual_kb_tag-apache-rewrite","manual_kb_tag-mod-rewrite","manual_kb_tag-redirect","manual_kb_tag-redirect-to-directory","manual_kb_tag-redirect-domain-to-directory","manual_kb_tag-subdirectory-redirect","manual_kb_tag-website-redirect","manual_kb_tag-rewrite-rules","manual_kb_tag-htaccess","manual_kb_tag-domain-redirect"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9652\/revisions"}],"predecessor-version":[{"id":9653,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9652\/revisions\/9653"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/media?parent=9652"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manualknowledgebasecat?post=9652"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb_tag?post=9652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}