{"id":1373,"date":"2016-05-20T20:02:42","date_gmt":"2016-05-20T18:02:42","guid":{"rendered":"https:\/\/www.nullalo.com\/?p=1373"},"modified":"2025-10-22T10:15:47","modified_gmt":"2025-10-22T08:15:47","slug":"moving-the-root-of-site-subdirectory","status":"publish","type":"post","link":"https:\/\/www.nullalo.com\/en\/moving-the-root-of-a-site-in-a-subdirectory\/","title":{"rendered":"Moving the root of a site in a subdirectory"},"content":{"rendered":"<p><\/p>\n<p>During the development of a site may be needed to move the root of site in a subdirectory of our web space. An example is the well-known laravel framework, which uses the <i>public<\/i> folder to accommodate the public file of the site.<\/p>\n<p>To do this you have to configure the .htaccess file in the root of the web space.<\/p>\n<h3>.htaccess<\/h3>\n<p>The .htaccess files are text files that contain Apache directives for the configuration. These files work in a simple way. When Apache receives a request, before carrying it out, see if there is an .htaccess file in the folder of the addressed or in a previous folder, if it exists Apache reads and interprets it at run-time and configures it with the directives contained within that file. Apache reloads the file to every request, this allows you to change the configuration at any time at run-time. The scope of the .htaccess file is the folder where the file is located, and will affect all files and subdirectories within it.<\/p>\n<h3>Method<\/h3>\n<p><strong>A)<\/strong> Create in your PC a file whit name .htaccess and copy the content below inside replacing mydomain.com with the domain of the site you want to change and subdirectory with the name of the folder to operate.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# www.nullalo.com\r\n# .htaccess main domain to subdirectory redirect\r\n# Do not change this line.\r\nRewriteEngine on\r\n# Change mydomain.com to be your main domain.\r\nRewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$\r\n# Change 'subdirectory' to be the directory you will use for your main domain.\r\nRewriteCond %{REQUEST_URI} !^\/subdirectory\/\r\n# Don't change the following two lines.\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\n# Change 'subdirectory' to be the directory you will use for your main domain.\r\nRewriteRule ^(.*)$ \/subdirectory\/$1\r\n# Change mydomain.com to be your main domain again.\r\n# Change 'subdirectory' to be the directory you will use for your main domain\r\n# followed by \/ then the main file for your site, index.html, index.php, etc.\r\nRewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$\r\nRewriteRule ^(\/)?$ subdirectory\/index.php&#x5B;L]\r\n<\/pre>\n<p><strong>B)<\/strong> Make a backup of the .htaccess file in the root of your website by copying it to a safe place.<\/p>\n<p><strong>C)<\/strong> Copy the file created in the root of your web space, if necessary force it to overwrite an existing file.<\/p>\n<p><strong>D)<\/strong> If there are problems you have to restore the previous file. In that case you will need to do a merge of the two files. This operation depend by your provider.<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Host a site in a subdirectory using .htaccess<\/p>\n","protected":false},"author":3,"featured_media":1393,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[46],"tags":[108,45],"class_list":["post-1373","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-strumenti-web","tag-hosting","tag-web"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Moving the root of a site in a subdirectory - Nullalo!<\/title>\n<meta name=\"description\" content=\"Host a site in a subdirectory using .htaccess\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.nullalo.com\/?p=1373\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Moving the root of a site in a subdirectory - Nullalo!\" \/>\n<meta property=\"og:description\" content=\"Host a site in a subdirectory using .htaccess\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.nullalo.com\/?p=1373\" \/>\n<meta property=\"og:site_name\" content=\"Nullalo!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/nullalo\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/oscar.talamo\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-20T18:02:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-22T08:15:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1140\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Oscar Talamo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/OscarTalamo\" \/>\n<meta name=\"twitter:site\" content=\"@Nullalo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oscar Talamo\" \/>\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\":\"WebPage\",\"@id\":\"https:\/\/www.nullalo.com\/?p=1373\",\"url\":\"https:\/\/www.nullalo.com\/?p=1373\",\"name\":\"[:it]Spostare la root di un sito in una subdirectory[:en]Moving the root of a site in a subdirectory[:] - Nullalo!\",\"isPartOf\":{\"@id\":\"https:\/\/www.nullalo.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.nullalo.com\/?p=1373#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.nullalo.com\/?p=1373#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg\",\"datePublished\":\"2016-05-20T18:02:42+00:00\",\"dateModified\":\"2025-10-22T08:15:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.nullalo.com\/#\/schema\/person\/8de011a243a40a6292babe6bc706491d\"},\"description\":\"Host a site in a subdirectory using .htaccess\",\"breadcrumb\":{\"@id\":\"https:\/\/www.nullalo.com\/?p=1373#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.nullalo.com\/?p=1373\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.nullalo.com\/?p=1373#primaryimage\",\"url\":\"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg\",\"contentUrl\":\"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg\",\"width\":1140,\"height\":600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.nullalo.com\/?p=1373#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.nullalo.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spostare la root di un sito in una subdirectory\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.nullalo.com\/#website\",\"url\":\"https:\/\/www.nullalo.com\/\",\"name\":\"Nullalo!\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.nullalo.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.nullalo.com\/#\/schema\/person\/8de011a243a40a6292babe6bc706491d\",\"name\":\"Oscar Talamo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.nullalo.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.nullalo.com\/wp-content\/uploads\/2015\/03\/Oscar-Talamo_avatar_1425630515-96x96.jpg\",\"contentUrl\":\"https:\/\/www.nullalo.com\/wp-content\/uploads\/2015\/03\/Oscar-Talamo_avatar_1425630515-96x96.jpg\",\"caption\":\"Oscar Talamo\"},\"sameAs\":[\"http:\/\/www.generalservice.na.it\",\"https:\/\/www.facebook.com\/oscar.talamo\",\"https:\/\/it.linkedin.com\/pub\/oscar-talamo\/29\/221\/ab4\",\"https:\/\/x.com\/https:\/\/twitter.com\/OscarTalamo\",\"https:\/\/www.youtube.com\/user\/ZarOscar76\"],\"url\":\"https:\/\/www.nullalo.com\/en\/author\/o-talamo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Moving the root of a site in a subdirectory - Nullalo!","description":"Host a site in a subdirectory using .htaccess","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:\/\/www.nullalo.com\/?p=1373","og_locale":"en_US","og_type":"article","og_title":"Moving the root of a site in a subdirectory - Nullalo!","og_description":"Host a site in a subdirectory using .htaccess","og_url":"https:\/\/www.nullalo.com\/?p=1373","og_site_name":"Nullalo!","article_publisher":"https:\/\/www.facebook.com\/nullalo","article_author":"https:\/\/www.facebook.com\/oscar.talamo","article_published_time":"2016-05-20T18:02:42+00:00","article_modified_time":"2025-10-22T08:15:47+00:00","og_image":[{"width":1140,"height":600,"url":"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg","type":"image\/jpeg"}],"author":"Oscar Talamo","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/OscarTalamo","twitter_site":"@Nullalo","twitter_misc":{"Written by":"Oscar Talamo","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.nullalo.com\/?p=1373","url":"https:\/\/www.nullalo.com\/?p=1373","name":"[:it]Spostare la root di un sito in una subdirectory[:en]Moving the root of a site in a subdirectory[:] - Nullalo!","isPartOf":{"@id":"https:\/\/www.nullalo.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.nullalo.com\/?p=1373#primaryimage"},"image":{"@id":"https:\/\/www.nullalo.com\/?p=1373#primaryimage"},"thumbnailUrl":"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg","datePublished":"2016-05-20T18:02:42+00:00","dateModified":"2025-10-22T08:15:47+00:00","author":{"@id":"https:\/\/www.nullalo.com\/#\/schema\/person\/8de011a243a40a6292babe6bc706491d"},"description":"Host a site in a subdirectory using .htaccess","breadcrumb":{"@id":"https:\/\/www.nullalo.com\/?p=1373#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.nullalo.com\/?p=1373"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.nullalo.com\/?p=1373#primaryimage","url":"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg","contentUrl":"https:\/\/www.nullalo.com\/wp-content\/uploads\/2016\/04\/web_hosting.jpg","width":1140,"height":600},{"@type":"BreadcrumbList","@id":"https:\/\/www.nullalo.com\/?p=1373#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.nullalo.com\/"},{"@type":"ListItem","position":2,"name":"Spostare la root di un sito in una subdirectory"}]},{"@type":"WebSite","@id":"https:\/\/www.nullalo.com\/#website","url":"https:\/\/www.nullalo.com\/","name":"Nullalo!","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.nullalo.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.nullalo.com\/#\/schema\/person\/8de011a243a40a6292babe6bc706491d","name":"Oscar Talamo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.nullalo.com\/#\/schema\/person\/image\/","url":"https:\/\/www.nullalo.com\/wp-content\/uploads\/2015\/03\/Oscar-Talamo_avatar_1425630515-96x96.jpg","contentUrl":"https:\/\/www.nullalo.com\/wp-content\/uploads\/2015\/03\/Oscar-Talamo_avatar_1425630515-96x96.jpg","caption":"Oscar Talamo"},"sameAs":["http:\/\/www.generalservice.na.it","https:\/\/www.facebook.com\/oscar.talamo","https:\/\/it.linkedin.com\/pub\/oscar-talamo\/29\/221\/ab4","https:\/\/x.com\/https:\/\/twitter.com\/OscarTalamo","https:\/\/www.youtube.com\/user\/ZarOscar76"],"url":"https:\/\/www.nullalo.com\/en\/author\/o-talamo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/posts\/1373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/comments?post=1373"}],"version-history":[{"count":1,"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/posts\/1373\/revisions"}],"predecessor-version":[{"id":1936,"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/posts\/1373\/revisions\/1936"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/media\/1393"}],"wp:attachment":[{"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/media?parent=1373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/categories?post=1373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nullalo.com\/en\/wp-json\/wp\/v2\/tags?post=1373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}