{"id":236,"date":"2024-05-06T06:06:31","date_gmt":"2024-05-06T06:06:31","guid":{"rendered":"https:\/\/zalvis.com\/docs\/?p=236"},"modified":"2024-06-23T05:27:23","modified_gmt":"2024-06-23T05:27:23","slug":"how-to-redirect-your-domain-to-a-subfolder-using-htaccess","status":"publish","type":"post","link":"https:\/\/zalvis.com\/docs\/how-to-redirect-your-domain-to-a-subfolder-using-htaccess.html","title":{"rendered":"How To Redirect Your Domain To A Subfolder Using htaccess"},"content":{"rendered":"<p>In this tutorial, we are going to show you a simple way to redirect your primary domain to a subfolder on that domain. For the purposes of this tutorial, it will redirect to a subfolder at \/blog.<\/p>\n<p>This is useful if your WordPress blog is installed to a subfolder and you want the main domain to forward to it.<\/p>\n<p>In your public_html folder (also called the \u201croot directory\u201d or \u201cdocument root\u201d), you need to create a file called<strong> .htaccess.\u00a0<\/strong>You can do so by using the File Manager in cPanel.<\/p>\n<p>From this file, we are going to use a few lines to redirect those requests in a search engine friendly way.<\/p>\n<p>Add the following lines to that file:<\/p>\n<p><code>RewriteEngine On<br \/>\nRewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$<br \/>\nRewriteRule ^(\/)?$ blog [L]<\/code><\/p>\n<p>The only change you need to make is to change \u201cyourdomain.com\u201d to your domain. This will then redirect everything from the domain to the folder \/blog at that domain. If you want to change that folder just edit the \u201cblog\u201d part.<\/p>\n<div class=\"gxkwx69d75dc830c2a\" >If you enjoyed this article, then you\u2019ll love Zalvis's Cloud Hosting platform. Turbocharge your website and get 24\/7 support from our veteran team. Our world-class hosting infrastructure focuses on auto-scaling, performance, and security. Let us show you the Zalvis difference! <a href=\"https:\/\/zalvis.com\/\">Check out our services.<\/a><\/div><style type=\"text\/css\">\r\n@media screen and (min-width: 1201px) {\r\n.gxkwx69d75dc830c2a {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 993px) and (max-width: 1200px) {\r\n.gxkwx69d75dc830c2a {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 769px) and (max-width: 992px) {\r\n.gxkwx69d75dc830c2a {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 768px) and (max-width: 768px) {\r\n.gxkwx69d75dc830c2a {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (max-width: 767px) {\r\n.gxkwx69d75dc830c2a {\r\ndisplay: block;\r\n}\r\n}\r\n<\/style>\r\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we are going to show you a simple way to redirect your primary domain to a subfolder on that domain. For the purposes of this tutorial, it will redirect to a subfolder at \/blog. This is useful if your WordPress blog is installed to a subfolder and you want the main domain [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-cpanel-hosting"],"_links":{"self":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/comments?post=236"}],"version-history":[{"count":3,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":962,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/236\/revisions\/962"}],"wp:attachment":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/media?parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/categories?post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/tags?post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}