{"id":3747,"date":"2023-11-21T14:42:57","date_gmt":"2023-11-21T06:42:57","guid":{"rendered":"https:\/\/www.servergigabit.com\/guide\/?post_type=kb&#038;p=3747"},"modified":"2026-03-17T11:09:09","modified_gmt":"2026-03-17T03:09:09","slug":"htaccess-rewrites-subfolder","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/htaccess-rewrites-subfolder","title":{"rendered":"The Ultimate Guide to htaccess Rewrites for Moving Website Content to a Subfolder"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3748\" src=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-300x169.jpeg\" alt=\"htaccess Rewrites\" width=\"717\" height=\"404\" srcset=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-300x169.jpeg 300w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-1024x576.jpeg 1024w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-768x432.jpeg 768w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-1536x864.jpeg 1536w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-2048x1152.jpeg 2048w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-370x208.jpeg 370w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-1230x692.jpeg 1230w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-800x450.jpeg 800w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/i-390x219.jpeg 390w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/p>\n<div class=\"markdown markdown-main-panel\" dir=\"ltr\">\n<p data-sourcepos=\"3:1-3:141\">Managing multiple domains and their associated content can become cumbersome, especially when the content is spread across different folders. This can lead to confusion and make it difficult to maintain a consistent and organized website structure. To address this issue,<a href=\"https:\/\/httpd.apache.org\/docs\/current\/mod\/mod_rewrite.html\" rel=\"nofollow noopener\" target=\"_blank\"> htaccess rewrites<\/a> offer a powerful solution for moving website content to a subfolder without affecting its appearance or functionality.<\/p>\n<p data-sourcepos=\"5:1-5:278\">This guide provides a detailed explanation of how to utilize htaccess rewrites to achieve a cleaner and more organized website structure. It outlines the steps involved in moving website content to a subfolder, configuring the necessary settings, and ensuring seamless operation of the website. Additionally, it provides specific instructions for configuring Joomla!<span class=\"animating\"> 3 and WordPress to work effectively with the new folder structure.<\/span><\/p>\n<p data-sourcepos=\"7:1-7:163\"><span class=\"animating\">By following this guide,<\/span><span class=\"animating\"> you can effectively manage your website&#8217;s content,<\/span><span class=\"animating\"> maintain a clean and organized file structure,<\/span><span class=\"animating\"> and enhance the overall user experience.<\/span><\/p>\n<h2 data-sourcepos=\"9:1-9:15\"><strong>Preparation to Utilize htaccess Rewrites<\/strong><\/h2>\n<ol data-sourcepos=\"11:1-18:0\">\n<li data-sourcepos=\"11:1-12:0\">\n<p data-sourcepos=\"11:4-11:68\">Start with a fresh account or create a full backup of your files.<\/p>\n<\/li>\n<li data-sourcepos=\"13:1-14:0\">\n<p data-sourcepos=\"13:4-13:86\">Create a sub-folder in \/public_html and name it after the domain, e.g. example.com.<\/p>\n<\/li>\n<li data-sourcepos=\"15:1-16:0\">\n<p data-sourcepos=\"15:4-15:68\">Move all content of your main domain to the newly created folder.<\/p>\n<\/li>\n<li data-sourcepos=\"17:1-18:0\">\n<p data-sourcepos=\"17:4-17:57\">If there already is a .htaccess file, move it as well.<\/p>\n<\/li>\n<\/ol>\n<h2 data-sourcepos=\"19:1-19:26\"><strong>htaccess Configuration<\/strong><\/h2>\n<ol data-sourcepos=\"21:1-22:0\">\n<li data-sourcepos=\"21:1-22:0\">Create a new .htaccess file in \/public_html and paste the following:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\">RewriteEngine on\r\nRewriteCond %{HTTP_HOST} ^example.com$ [OR]\r\nRewriteCond %{HTTP_HOST} ^www.example.com$\r\nRewriteCond %{REQUEST_URI} !^\/example.com\r\nRewriteRule ^(.*)$ example.com\/$1 [L]\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"2\" data-sourcepos=\"31:1-34:0\">\n<li data-sourcepos=\"31:1-32:0\">\n<p data-sourcepos=\"31:4-31:52\">Replace example.com with your actual domain name.<\/p>\n<\/li>\n<li data-sourcepos=\"33:1-34:0\">\n<p data-sourcepos=\"33:4-33:96\">Save the file and open the domain in your browser. The website should be displayed correctly.<\/p>\n<\/li>\n<\/ol>\n<h2 data-sourcepos=\"35:1-35:44\"><strong>Updating Website Configuration (Joomla!)<\/strong><\/h2>\n<ol data-sourcepos=\"37:1-38:0\">\n<li data-sourcepos=\"37:1-38:0\">Modify the following line in configuration.php:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-variable\">$live_site<\/span> = <span class=\"hljs-string\">'https:\/\/www.example.com\/'<\/span>;\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"2\" data-sourcepos=\"43:1-44:0\">\n<li data-sourcepos=\"43:1-44:0\">If you use URL Rewriting in Joomla!, edit the following line in the .htaccess file in the sub-folder of your domain:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\">RewriteBase \/example.com\r\n<\/code><\/pre>\n<\/div>\n<h2 data-sourcepos=\"49:1-49:46\"><strong>Updating Website Configuration (<a href=\"https:\/\/www.servergigabit.com\/\">WordPress<\/a>)<\/strong><\/h2>\n<ol data-sourcepos=\"51:1-52:0\">\n<li data-sourcepos=\"51:1-52:0\">Modify the following lines in wp-config.php:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container\" role=\"text\">define(<span class=\"hljs-string\">'WP_HOME'<\/span>,<span class=\"hljs-string\">'https:\/\/example.com'<\/span>);\r\ndefine(<span class=\"hljs-string\">'WP_SITEURL'<\/span>,<span class=\"hljs-string\">'https:\/\/example.com'<\/span>);\r\n<\/code><\/pre>\n<\/div>\n<h2 data-sourcepos=\"58:1-58:14\"><strong>Conclusion<\/strong><\/h2>\n<p data-sourcepos=\"60:1-60:215\"><span class=\"animating\">By implementing these steps and making the necessary adjustments,<\/span><span class=\"animating\"> you can successfully move your website&#8217;s content to a subfolder without affecting its appearance.<\/span><span class=\"animating\"> The new folder structure will be more organized and easier to manage.<\/span><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Managing multiple domains and their associated content can become cumbersome, especially when the content is spread across different folders. This can lead to confusion and make it difficult to maintain a consistent and organized website structure. To address this issue, htaccess rewrites offer a powerful solution for moving website content to a subfolder without affecting its appearance or functionality. This&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[1099],"kbtag":[1183],"class_list":["post-3747","kb","type-kb","status-publish","hentry","kbtopic-tutorials","kbtag-htaccess-rewrites"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=3747"}],"version-history":[{"count":5,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3747\/revisions"}],"predecessor-version":[{"id":6348,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3747\/revisions\/6348"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=3747"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3747"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}