{"id":6978,"date":"2020-10-08T19:06:47","date_gmt":"2020-10-08T19:06:47","guid":{"rendered":"https:\/\/tutorialsclass.com\/?p=6978"},"modified":"2020-10-22T20:05:26","modified_gmt":"2020-10-22T20:05:26","slug":"htaccess-directoryindex","status":"publish","type":"post","link":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/","title":{"rendered":"Htaccess DirectoryIndex"},"content":{"rendered":"\n<p>The DirectoryIndex directive allow you to set the default page when a directory is accessed. When a user visits your website, the server looks for the default index file.<\/p>\n\n\n\n<p>Some examples of common index files are:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>index.htm<\/li><li>index.html<\/li><li>index.php<\/li><li>index.cgi<\/li><li>index.pl<\/li><li>index.txt<\/li><\/ul>\n\n\n\n<p>If the directory has index.html, it will be loaded by default. So if a user visits <strong>https:\/\/example.com\/<\/strong> then <strong>https:\/\/example.com\/index.html<\/strong> will be loaded<\/p>\n\n\n\n<p><strong>Syntax:<\/strong> <code>DirectoryIndex file<\/code>-name<\/p>\n\n\n\n<p>Using .htaccess file, you can set the different index file name also. You can also set multiple files with the order you want to look for.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Example of DirectoryIndex :<\/h2>\n\n\n\n<p>Here is an example to set multiple index files using Htaccess DirectoryIndex.<\/p>\n\n\n\n<pre class=\"wp-block-code language-htaccess\"><code>DirectoryIndex index.php index.html home.html page.html<\/code><\/pre>\n\n\n\n<p>In this example, the server first checks if <strong>index.php<\/strong> exists. If PHP file not found, it will check for <strong>index.html<\/strong>, <strong>home.html<\/strong> and <strong>page.html<\/strong> next. Whatever file it will find first, it will be loaded.<\/p>\n\n\n\n<p><strong>Note:<\/strong> If you want same index page as a default for all subfolders in a website, set the DirectoryIndex directive to the .htaccess file in the public_html or root directory.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Fail safe directory listing:<\/h2>\n\n\n\n<p>We can <strong>set single default file<\/strong> for all subdirectories in a website if there is no default index file found in any subdirectory. <\/p>\n\n\n\n<pre class=\"wp-block-code language-htaccess\"><code>Options -Indexes\nDirectoryIndex index.php index.html \/site-default.php<\/code><\/pre>\n\n\n\n<p>In this example, if any subdirectory or folder does not have <strong>index.php<\/strong> and <strong>index.html<\/strong>, then \/<strong>site-default.php<\/strong> will be loaded from the root folder.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>htaccess DirectoryIndex tutorial with an example. Learn how to set the default directory index page in your website using .htaccess.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[190],"tags":[],"keywords":[],"class_list":["post-6978","post","type-post","status-publish","format-standard","hentry","category-htaccess"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Htaccess DirectoryIndex - Set default index page - Tutorials Class<\/title>\n<meta name=\"description\" content=\"htaccess DirectoryIndex tutorial with an example. Learn how to set the default directory index page in your website 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:\/\/tutorialsclass.com\/htaccess-directoryindex\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Htaccess DirectoryIndex - Set default index page - Tutorials Class\" \/>\n<meta property=\"og:description\" content=\"htaccess DirectoryIndex tutorial with an example. Learn how to set the default directory index page in your website using .htaccess.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorials Class\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/tutorialsclass\" \/>\n<meta property=\"article:published_time\" content=\"2020-10-08T19:06:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-10-22T20:05:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Tutorials Class\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:site\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tutorials Class\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/\"},\"author\":{\"name\":\"Tutorials Class\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\"},\"headline\":\"Htaccess DirectoryIndex\",\"datePublished\":\"2020-10-08T19:06:47+00:00\",\"dateModified\":\"2020-10-22T20:05:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/\"},\"wordCount\":244,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"articleSection\":[\"Htaccess\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/\",\"url\":\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/\",\"name\":\"Htaccess DirectoryIndex - Set default index page - Tutorials Class\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/#website\"},\"datePublished\":\"2020-10-08T19:06:47+00:00\",\"dateModified\":\"2020-10-22T20:05:26+00:00\",\"description\":\"htaccess DirectoryIndex tutorial with an example. Learn how to set the default directory index page in your website using .htaccess.\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorialsclass.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learn\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Htaccess\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/htaccess\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Htaccess DirectoryIndex\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorialsclass.com\/#website\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"name\":\"Tutorials Class\",\"description\":\"Online Tutorials for Beginners\",\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorialsclass.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/tutorialsclass.com\/#organization\",\"name\":\"Tutorials Class\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"contentUrl\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"width\":442,\"height\":94,\"caption\":\"Tutorials Class\"},\"image\":{\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/tutorialsclass\",\"https:\/\/x.com\/TutorialsClass\",\"https:\/\/in.pinterest.com\/merientinfotech\/boards\/\",\"https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\",\"name\":\"Tutorials Class\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"caption\":\"Tutorials Class\"},\"sameAs\":[\"tcadmin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Htaccess DirectoryIndex - Set default index page - Tutorials Class","description":"htaccess DirectoryIndex tutorial with an example. Learn how to set the default directory index page in your website 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:\/\/tutorialsclass.com\/htaccess-directoryindex\/","og_locale":"en_US","og_type":"article","og_title":"Htaccess DirectoryIndex - Set default index page - Tutorials Class","og_description":"htaccess DirectoryIndex tutorial with an example. Learn how to set the default directory index page in your website using .htaccess.","og_url":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/","og_site_name":"Tutorials Class","article_publisher":"https:\/\/www.facebook.com\/tutorialsclass","article_published_time":"2020-10-08T19:06:47+00:00","article_modified_time":"2020-10-22T20:05:26+00:00","og_image":[{"width":600,"height":600,"url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png","type":"image\/png"}],"author":"Tutorials Class","twitter_card":"summary_large_image","twitter_creator":"@TutorialsClass","twitter_site":"@TutorialsClass","twitter_misc":{"Written by":"Tutorials Class","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#article","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/"},"author":{"name":"Tutorials Class","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e"},"headline":"Htaccess DirectoryIndex","datePublished":"2020-10-08T19:06:47+00:00","dateModified":"2020-10-22T20:05:26+00:00","mainEntityOfPage":{"@id":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/"},"wordCount":244,"commentCount":0,"publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"articleSection":["Htaccess"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/","url":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/","name":"Htaccess DirectoryIndex - Set default index page - Tutorials Class","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/#website"},"datePublished":"2020-10-08T19:06:47+00:00","dateModified":"2020-10-22T20:05:26+00:00","description":"htaccess DirectoryIndex tutorial with an example. Learn how to set the default directory index page in your website using .htaccess.","breadcrumb":{"@id":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorialsclass.com\/htaccess-directoryindex\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tutorialsclass.com\/htaccess-directoryindex\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorialsclass.com\/"},{"@type":"ListItem","position":2,"name":"Learn","item":"https:\/\/tutorialsclass.com\/learn\/"},{"@type":"ListItem","position":3,"name":"Htaccess","item":"https:\/\/tutorialsclass.com\/learn\/htaccess\/"},{"@type":"ListItem","position":4,"name":"Htaccess DirectoryIndex"}]},{"@type":"WebSite","@id":"https:\/\/tutorialsclass.com\/#website","url":"https:\/\/tutorialsclass.com\/","name":"Tutorials Class","description":"Online Tutorials for Beginners","publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorialsclass.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/tutorialsclass.com\/#organization","name":"Tutorials Class","url":"https:\/\/tutorialsclass.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/","url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","contentUrl":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","width":442,"height":94,"caption":"Tutorials Class"},"image":{"@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/tutorialsclass","https:\/\/x.com\/TutorialsClass","https:\/\/in.pinterest.com\/merientinfotech\/boards\/","https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA"]},{"@type":"Person","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e","name":"Tutorials Class","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","caption":"Tutorials Class"},"sameAs":["tcadmin"]}]}},"_links":{"self":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/6978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/comments?post=6978"}],"version-history":[{"count":7,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/6978\/revisions"}],"predecessor-version":[{"id":7078,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/6978\/revisions\/7078"}],"wp:attachment":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/media?parent=6978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/categories?post=6978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/tags?post=6978"},{"taxonomy":"keywords","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/keywords?post=6978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}