{"id":535,"date":"2017-03-15T00:00:00","date_gmt":"2017-03-15T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/%category\/htaccesshow-to-change-your-default-index-page-in-htaccess\/"},"modified":"2026-03-09T19:20:09","modified_gmt":"2026-03-09T19:20:09","slug":"change-index-page-in-htaccess-with-directoryindex","status":"publish","type":"post","link":"\/ng\/tutorials\/change-index-page-in-htaccess-with-directoryindex","title":{"rendered":"How to use directoryindex and .htaccess to change your website&#8217;s default index page"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>In this article, we will show you how to change and modify the first page of your website using the <strong>DirectoryIndex<\/strong> command in the <strong>.htaccess<\/strong> file. Let&rsquo;s check it out!<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/How-to-Speed-Up-Your-Website-EN.pdf\"><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website.png\/public\" alt=\"\" class=\"wp-image-69260\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook-Speed-Up-your-website.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-does-the-index-file-work\">How does the index file work?<\/h2><p>When you open a website on any browser, a typical web server will look for a file called<strong> index.html<\/strong> or <strong>index.php<\/strong> in its <strong>public_html<\/strong> files to load and deliver that file&rsquo;s content to your browser.<\/p><p><strong>DirectoryIndex<\/strong> is a command that lets you modify the index files of your website easily in the <strong>.htaccess<\/strong> file. It&rsquo;s used to specify which files should be loaded first by the page when your website is accessed.<\/p><p>You can also set up a second, third, and more files to be loaded by the server next in case there&rsquo;s any error preventing the designated first page to load.<\/p><h2 class=\"wp-block-heading\" id=\"h-locating-and-accessing-the-htaccess-file\">Locating and accessing the .htaccess file<\/h2><p>The first thing you need to do is locate or create a new <strong>.htaccess<\/strong> file in the WordPress root directory or in our case, <strong>public_html<\/strong>. Here&rsquo;s how:<\/p><ol class=\"wp-block-list\">\n<li>Login to Hostinger&rsquo;s hPanel, so to your site&rsquo;s dashboard, and navigate to <strong>Files<\/strong> &rarr;<strong> File Manager<\/strong>.<\/li>\n\n\n\n<li>You can also <a href=\"\/ng\/tutorials\/ftp\/filezilla-ftp-configuration\">configure an FTP client<\/a> such as <a href=\"https:\/\/filezilla-project.org\/\">FileZilla<\/a> to access the directory from a local computer.<\/li>\n\n\n\n<li>Once you&rsquo;re in the<strong>&nbsp;public_html<\/strong> directory, locate the<strong> .htaccess<\/strong> file. If it doesn&rsquo;t exist, you can quickly create one by going to the upper part of the page and selecting the <strong>New File<\/strong> function.<br><img loading=\"lazy\" decoding=\"async\" width=\"613\" height=\"101\" class=\"aligncenter wp-image-20738\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2017\/03\/Creating-a-New-.htaccessfile.png\" alt=\"this image shows you how to create a new htaccess file in File Manager\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2017\/03\/Creating-a-New-.htaccessfile.png\/w=352,fit=scale-down 352w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2017\/03\/Creating-a-New-.htaccessfile.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2017\/03\/Creating-a-New-.htaccessfile.png\/w=300,fit=scale-down 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/li>\n\n\n\n<li>Once you&rsquo;re prompted with a file creation box, enter <strong>.htaccess<\/strong>, then press<strong> Create<\/strong> to save the file.<\/li>\n<\/ol><p>It&rsquo;s worth mentioning that locating the <a href=\"\/ng\/tutorials\/locate-and-create-htaccess\">.htaccess file<\/a> on cPanel follows a similar process.<\/p><h2 class=\"wp-block-heading\" id=\"h-editing-htaccess-to-add-the-directoryindex-command\">Editing .htaccess to add the DirectoryIndex command<\/h2><p>To modify the first page loaded by your website using the <strong>DirectoryIndex<\/strong> command, follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>Head to <strong>.htaccess<\/strong>&nbsp;and right-click to<strong> Edit<\/strong>.<\/li>\n\n\n\n<li>Paste the following code at the top of the file to configure your desired index page:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DirectoryIndex example.html<\/pre><p>Remember to replace&nbsp;<strong>example.html<\/strong> with the page you want to use.<\/p><p>You can also list more than one file in the configuration. In this example, we add <strong>first.html<\/strong>, <strong>index.html<\/strong>, and <strong>index.php<\/strong> to the list.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"203\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2017\/03\/directoryindex-input-example.png\/public\" alt=\"this image shows you an example of directoryindex input in .htaccess\" class=\"wp-image-20737\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2017\/03\/directoryindex-input-example.png\/w=599,fit=scale-down 599w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2017\/03\/directoryindex-input-example.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2017\/03\/directoryindex-input-example.png\/w=300,fit=scale-down 300w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/figure><\/div><p>Your specified index files will be read and checked from left to right. First, the server will look for<strong> first.html, <\/strong>and if it doesn&rsquo;t find a file with that name, it continues to <strong>index.html<\/strong> and so on.<\/p><p>You can also use this command to set up a temporary error page where your visitors will be directed to in case your page unexpectedly crashes. Here&rsquo;s an example:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DirectoryIndex index.php page-down.php<\/pre><p>Once the desired code is added, don&rsquo;t forget to save the changes, and the configuration will take effect.<\/p><p>Congratulations, you have successfully changed the default index page of your website by manipulating the .htaccess file!<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-web-hosting\" href=\"\/ng\/web-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/public\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>In this tutorial, we have learned how to effectively change the first page on your website using <strong>DirectoryIndex<\/strong> in the .<strong>htaccess <\/strong>file. In case you have any other cool tips that you want to share with us, you are welcome to do so in the comments!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will show you how to change and modify the first page of your website using the DirectoryIndex command in the .htaccess file. Let&rsquo;s check it out! How does the index file work? When you open a website on any browser, a typical web server will look for a file called index.html [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/change-index-page-in-htaccess-with-directoryindex\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":24,"featured_media":145390,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"%title%","rank_math_description":"Want to change your default index page on your website? Check out our tutorial and learn how to do it easily with directoryindex in .htaccess!","rank_math_focus_keyword":"directoryindex","footnotes":""},"categories":[22630],"tags":[],"class_list":["post-535","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-aspects"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/changer-page-accueil-htaccess","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-mengganti-file-index-dengan-htaccess","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/change-index-page-in-htaccess-with-directoryindex","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=535"}],"version-history":[{"count":15,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/535\/revisions"}],"predecessor-version":[{"id":145389,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/535\/revisions\/145389"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media\/145390"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}