How to Change your Default Index Page in .htaccess

The server looks for specifically named files as the first page of your website, also known as the index page. The default order of index file names our particular servers look through is index.htm, index.html, index.php, and finally default.htm. You can change the name of the index file your account looks for by altering the .htaccess file. Perhaps you want to have a specific custom name for your index file or maybe you are migrating from another host and the index page is named differently. This way your internal links will not be broken by renaming the index file.

Don’t have time to read the article on how to change your default index page in .htaccess? Watch our walk-through video.

What is an htaccess File?

The .htaccess file is a hidden text file within your hosting account that can be very powerful. It is designed so that you can modify it to change the behavior of your website that normally would take higher access beyond your account. It acts as a liaison between your domain and the server and can perform many functions.
Learn more about htaccess

Changing your Default Index File via htaccess

  1. Log into your cPanel.
  2. Find the Files category and click on the File Manager icon.


  3. Click Settings at the top right corner.


  4. Select the document root for the domain you are working with and be sure the checkbox next to Show Hidden Files is checked. Click the Save button.


  5. Look for the .htaccess file and right click on it. This brings up a menu. Find and click on the Edit option.


  6. You may be presented with a popup. Click on the Edit button. file-manager-htaccess
  7. You are now in the htaccess editor. Paste the following code at the top of the page to configure your desired index page. In our example below, we decided to make the index page of our folders named first.html.
    #Alternate default index page
    DirectoryIndex first.html

    You can also list more than one file in the configuration. The file will be read left to right and check for them in that order. In this example, we add index.htm, index.html, and index.php to the list. First the server will check for first.html, if it does not find a file with that name, it continues to index.htm and so on.

    #Alternate default index pages
    DirectoryIndex first.html index.htm index.html index.php
  8. Be sure to hit the Save Changes button in the upper right corner to save your new htaccess configuration.

137 thoughts on “How to Change your Default Index Page in .htaccess

  1. My in my website subdomains redirects to main domain 404 the website is in php how can i fix it please

  2. This guide is absolutly fenomenol Please reqiust to you how I can display the header and footer with my custom code on entire site with help of PHP.
    I am using wordpress cms

  3. My website running on but showing error on How can I resolve this issue as I read your article and did the things you mentioned above but not working for me.

  4. I have set the ‘htaccess’ file according to my bindex file. But this still can’t, please ask for a solution to this

    Thank you very much

    1. You may have to clear your browser cache before testing or try in a different browser. Also, check if there are other .htaccess files in a higher level “parent” folder. As it may be inheriting rules from that file.
      Thank you,

  5. I loaded up only my WordPress CMS Blog Website to domain and want the domain to default to which is where my CMS Blog Website resides. 

    In which file would I insert the following?


    RewriteCond %{HTTPS_HOST} ^


    RewriteRule ^(.*) [P]








    Please help because I want the to open all the times – default.





    1. Thanks for posting your comment regarding where you should place the code you are using. Since you are using a CMS–WordPress, I do not recommend using the .htaccess to configure this. You can use the define statements in your wp-config.php file for WordPress or you can simply use the Dashboard to configure this. Check out our guide: “Changing the Site URL and Home Settings” to learn a couple ways this can be done since you’re using WordPress.

  6. How do I replace the default HOME page from CodeIgniter to the HOME Page of WordPress (rest other pages will stay in CodeIgniter) ?

    1. WordPress automatically creates links to its pages, so you can’t really use it as a front end website for another site, UNLESS you’re using the WordPress site ONLY for that purpose. I mean that you would create the WordPress site, and not include anything on its front page except links that go to your Codeigniter site. Your Codeigniter pages would need to point to the WordPress site as the home page. You would need to use a STATIC front page on WordPress and make sure the user can’t exit to anything that is normally related to the WordPress site. Honestly, I wouldn’t recommend that you do that, because you’re basically mashing too different systems together but it is your preference, of course.

    2. This is a common coding issue that has been addressed many different ways. We unfortunately cannot provide your a coding solution (coding problems are beyond the scope of our support), but you may find solutions posted in place like this one.

  7. How can i set index.html for different locations (e.g. index-za.html for South Africa & index-uk.html for the united kingdom ? So basicly Based on your location it will display a index assigned to you location

  8. I have managed WordPress account in GoDaddy,  in .htaccess file in I have given

    DirectoryIndex index.html index.php both files  if I gave domain/index.html the html file getting called if I gave domain/index.php the php file not getting called still it is opening the index.html file only.

    but in the local environment both the files getting called.In Godaddy i have the problem.

    Any idea on this

    1. Have you tried removing the HTML file? If you already have an index.php file for WordPress then you do not need an index.html file.

    1. You will need to add HTML code if your coming soon page is an HTML page. If you’re using a plugin, you may be able to add it through the plugin depending on what you’re using and you have created the page. Check out this article to learn about using HTML, or consult with the developer of your plugin for more information.

    1. The instructions in this article take you through the steps of how to change it. If you are trying to do something else, please specify that in your question. If you require further assistance, you can contact the live technical support team via chat/phone/email.

  9. Hi! I need help. I uninstalled WordPress and my .htaccess file was deleted during the uninstall. I have created a new one but changing the file conrents has no effect. The old rules from the WordPress install are still in effect on my site. What do I neeed to do? 

    1. Hello,

      The default rules in .htaccess are normally surrounded by remarks in order to identify the section that they added. If you need to see what they add by default, please see default WordPress .htaccess entries.

      If you have any further questions, please let us know.

      Kindest regards,
      Arnel C.

  10. I have hosting for two sites from Inmotion, I am trying to create the Underconsruction page. In the file manager i can see the .htaccess file but it is pointing to my first site which i hosted. How can i change the .htaccess file for second site i am hosting on Inmotion.

    1. Kunal, all you need to do is create a new .htaccess file in the directory of your new site. So if your primary domain is in /home/userna05/public_html and your new domain’s directory is /home/userna05/ then you would need to create /home/userna05/

    1. Yes, you will just update the redirect to use the name of the “under construction” html file. Following the example above, you would replace “first.html” with the filename for the “under construction” page.

    1. Erin, you may need to place your .htaccess file in a different directory than the one that it is currently in based on your domain’s document root if you’re not seeing the code operate as you’ve expected. I recommend contacting your web host’s Support for account specific assistance, if possible.

  11. when I rename inde.html it works fine.. 

    problems occur when I changed index.php to another name

    home.php not get an ht access.. it default run index.php .. plz give me right solution. I need your help

    1. Hello Vaihali,

      The instructions above tell you how to use DirectoryIndex to specify a DIFFERENT name for your index file. So, if it’s named home.php, then you can specify that file as your index file by using the directoryindex command in the .htaccess file.

      If you have any further questions or comments, please let us know.

      Arnel C.

  12. I’m trying to create a default index page. I followed the instructions but am still confused what needs to be included on the .htaccess page

    1. The .htaccess file is actually hidden. You will use the code provided in your .htaccess file to point to the file you want to be displayed as your index page.

  13. Thank You! Finally, easy to understand and implement. Excellent for those of us that do not use or understand code.

  14. Hello,


    If i want the first page to acces to be a file in a folder like: eng/home.php what should i do? When i set the sefault page to eng/home.php it works fine but when i click on the menu the path is not IN that folder. For example i go to the defaut page which is eng/home.php an then when i navigate to e.g eng/info.php it gows to info.php and as a result the page does not exists.



    1. Hello Iraklis,

      Thank you for contacting us. If you are using a CMS such as WordPress, Joomla, etc. you may have to update your directory setting. These steps will differ based on the specific CMS.

      Thank you,

    2. I am not using cms the website is pure code. I am askingif there is a way to set for defaulte page in .htaccess a file that is inside a folder and ‘stay’ there so i can navigate to files inside that folder without using href=”../……..” but using href=”…….”

    3. Hello Beciaris,

      That would not be possible unless you moved all the other files to the same folder or coded up a function to set a base path which is how CMS tools do it.

      Best Regards,
      TJ Edens

  15. Hi, i am new to this webserver. I just made domain 

    www.**********.com, but not able to open my default page which i made in html.

  16. I have done followed the steps but when i search the website this is what i see.


    404. That’s an error.

    The requested URL / was not found on this server. That’s all we know

    1. Hello Polite,

      Make sure the page you are having the .htaccess file point to exists in your account. If not, then you will get a 404 error.

      Kindest Regards,
      Scott M

  17. Hello TJEdens Sir,

    Sir your code not working in .htacesss file

    RewriteEngine On
    RewriteRule ^([^/]*)$ /female.php?name=$1 [NC,OR]
    RewriteRule ^([^/]*)$ /male.php?name=$1 [L,NC]


    Sir please give me solution?

    1. Hello Ved Parksh,

      Sorry for the problem with the .htaccess code. Do you get any errors? What’s happening when you try the code? I have asked TJ to review the code for you and he should reply with some further information. Check out this tutorial on query redirects for .htaccess. It may help you resolve the issue as well.

      Kindest regards,
      Arnel C.

  18. Sir my 2 pages this link

    I want to this like url

    how to using .htaccess code please give me help

    1. Hello Ved,

      You should be able to perform what you are looking for with the code below:

      RewriteEngine On
      RewriteRule ^([^/]*)$ /female.php?name=$1 [NC,OR]
      RewriteRule ^([^/]*)$ /male.php?name=$1 [L,NC]

      Best Regards,
      TJ Edens

  19. The workaround to this is just to set the WP “site URL” to in general settings. Then set it back to just the domain and deprioritize the html index priority in .htaccess to launch.


    1. Hello,

      I’m sorry to hear about the problem you’re having with your website. We would need a little more information on the issue in order help you. Can you provide a URL? Any error messages? Steps to duplicate the problem? Please provide some information and we would be happy to investigate the issue further.

      Arnel C.

  20. there are no .htaccess on my server for me to edit the website is not displaying,i dont know what the problem is….i need some help


  21. I guess the only trouble I have in testing this is that the wordpress home page can’t be reached by simply typing in (it just defaults to the first file type, and that page).

    I can get to wp-admin and other pages, but index.php defaults to the html page I set.

    I’m guessing there’s a way around this though.

  22. Thanks for the feedback TJ. We’re planning to migrate our reseller base to you guys in early 2016. Your responsiveness (here and elsewhere) is a big part of that decision.

  23. With all the different types of ideas out there about how to redesign and relaunch an old html or shtml site as a new wordpress site (for example) without having to move files and worry about relative file structure and SEO, changing root folder file priorities seems the simplest. 

    Why not just prioritize the old index file (in my case index.shtml for many older sites) and build the WP site in the same root directory. The domain name will call the old index.shtml and no one will see index.php while you are working on the new site unless they type in index.php. Meanwhile both versions of site exists the whole time in root directory. Then when ready to relaunch, do your 301 redirects and then alter htaccess back to default (or just remove) and all pages will still exist but domain URL will now call the new site index.php. No big transfer of files. 

    I guess the only question is how to do it best:

    This might be one way:

    But your .htaccess mod may be easier, and doesn’t require a reboot. Am I missing something here? The other recommendations I’ve heard and read about with moving files from a local machine to web or from folder to folder seem much more precarious.


    1. Hello Wil,

      No you seem to have hit all the points as I would suggest the .htaccess method as well. Thank you for your input.

      Best Regards,
      TJ Edens

  24. I want an landing page with a big image, after clicking on the image the homepage shoul appear. I am using prestashop. Please anyone help me.

    1. Hello Riya,

      There is no way to do this in PrestaShop natively, however if you have PrestaShop located in a folder called /shop then you could have an index page that when clicked (or what ever the action you want to be) it redirects to

      Best Regards,
      TJ Edens

  25. i have built my website in core php but when i make my default page index.php then its title shows untitled document even though i have changed my title part how can i resolve this issue

    1. Hello konarch,

      Thank you for contacting us. When you make a change, you may have to clear your browser cache before testing.

      Also, as a test you can try creating an index.htm file, and just putting some text. This should display in your browser. Then remove it, and the index.php file should load.

      Thank you,

  26. I’ve changed this file to redirect me to the blog, but now I want the default file. where can I get it?

    1. Hello Mo’az,

      Thank you for contacting us. By default, there is no .htaccess file in your account. But, you can simply create a new file named .htaccess and use it.

      Alternately, if you are using a CMS (such as WordPress, Drupal, Joomla) you can download its default .htaccess file from them. Be sure to download the exact same version you are using for your site.

      Thank you ,

  27. I am hoping to set up a Prestashop site with inmotion but I want visitors directed to a custom “coming soon” teamplate that I purchased separately.  It is NOT a prestashop plugin but a standalone template with separate css, js, etc. files.  My concern is that some of these files and folders may be named the same in Prestashop and I would assume that will create problems.  Is it possible to place all of the coming soon files and folders in a separate folder and use the htaccess file to access the index.html within that folder so visitors will be directed to my coming soon page while I get my Prestashop site completed?  Or…is there some other approach I should take?  I’ve worked hard to set up the coming soon page just the way I want and I don’t want to have to abandon it.  

    1. Hello Dan,

      Yes, just put the folder name in the front of the file name “folder/index.html” for instance.

      Kindest Regards,
      Scott M

  28. i receive the error message after i transfered from wamp to online server.i dont know the next file to edit so that it will start confused here.can some one help me out

    Unable to open WampServer’s config file, please change path in index.php file

    1. Hello Chris,

      Is the server you are using online a WAMP server as well? This may not work if you try uploading content directly from WAMP to linux or windows servers. Can you provide the error that you are getting so we may try to troubleshoot further.

      Best Regards,
      TJ Edens

  29. HI. How To set The default URL for same page in my Website..

    Like., My website is ., and I want to set the default URL is in every pages of my websites .. So How can I do  This ??


    1. Hello Abhay,

      Your best bet would be to put a 301 redirect in your .htaccess as in the example below:

      RewriteCond %{HTTP_HOST} ^
      RewriteRule ^(.*)$1 [P]

      Best Regards,
      TJ Edens

  30. HI


    I have just registered my domain, website is under construction. I have tried the above, however seems there is NO .htaccess File.

    Any help would be much apprectiated

    1. Hello Alex,

      The .htaccess is a hidden file. If you’re using the cPanel File Manager and you have not set it to view hidden files, then you will not see the .htaccess file. You can reset the File Manager settings by logging into cPanel and then going to the bottom of the screen and selecting “reset all interface settings”. Then when you go into the file manager, make sure to click on “Show Hidden Files”. This will let you see the .htaccess file. If you created an .htaccess file previously, remember that case (no capital letters) and the period at the front of the file name are required for this file to operate correctly.

      I hope this helps to answer your question, please let us know if you require any further assistance.
      Arnel C.

  31. I checked the article but my situation is unique I think. It doesn’t help. Thanks for your help anyway. I have to submit this in to another website. I hope someone will help 🙁



  32. I’m doing SEO for a website. I want to redirect all old URLs to new URLs but all old URLs going to the home page. The guy who did the new website added htaccess coding. I can see two htaccess files in the server. One file is htaccess and second file is htaccess- Website is not working if I deleted one of them.

    This is the first htaccess file coding

    DirectoryIndex index.php
    RewriteEngine on
    RewriteCond %{QUERY_STRING} ^ln=([a-z]+)$
    RewriteRule ^chi/area_sta.php [L,R=301]
    RewriteCond %{QUERY_STRING} ^ln=([a-z]+)$
    RewriteRule ^chi/chi.php [L,R=301]
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
    RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]  

    This is the second htaccess- file coding

    DirectoryIndex index.php
    RewriteEngine on
    #RewriteCond %{HTTP_HOST} !^www\.
    #RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
    RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]  

    I Know 301 permanent URL redirect but when I put them they just go to the home page. Please help me. Tell me should I do. Thank you very much. This website is manual coding cms system. There are another two htacess files in “system” and “application” folder but when I open it says “Deny from all” I’m asking this same question since 2 weeks ago on other forums but no one helps. Please help

    1. Hello Amit,

      It appears you are using IIS and ASP for your site. This article is for APache web servers. IIS does not have a .htaccess file. It uses a file named web.config. It will have its own format for changing the default index page.

      Kindest Regards,
      Scott M

    1. Hello amit,

      Thank you for your question. Are you using a CMS such as Joomla, WordPress, etc? If so, it may be easier to set this up in the Admin Dashboard.

      Can you provide a link to your site? This will allow us to view your current setup.

      Thank you,

  33. Hello

    I am not happy with search results for my website’s homepage.  My website is built in magento and when i search for “raw audio brand” in Google. My search result for homepage appears as “raw audio raw audio” twice a time. I don’t like this. Even my homepage title is different.

    Can anyone help me to resolve this issue or any guidance.





    1. Hello Arun,

      Sorry for the problem with the search result. You can (and should) take the issue up directly with Google using Google’s WebMaster tools. You should also look at the search terms and any text being used to describe your site. It would also help if you provided information on your website such as the URL and how you built it. Please provide us a little more information and we can look into the issue further.

      If you have any further questions or comments, please let us know.

      Arnel C.

    2. Hello Pentanol,

      We’re not sure what you’re asking, because once you have WordPress installed, the first thing that appears when you type your website URL, is the home page. Your internet browser goes to the page that you set it to go. If you’re trying to make the WordPress site your home page, then you need to set your browser settings to do that. WordPress also has an Administrator login page. That is not the first page of the actual website – just checking to make sure that you are aware of this. If you can please explain exactly what you’re trying to do, then we can try to provide further assistance.

      If you have any further questions or comments, please let us know.

      Arnel C.

    3. Just what i needed where i am working on my site but i want my vistors to see that we are still making it and for the home to be index.html not index.php

  34. hello Mr. TJ

    I’m using prestashop.
    I‘ve cleared the cache, but the result remains the same.

    for my .htaccess i set permissions 777, is this wrong?
    there is also a confusing me, I use two languages, but why when I changed the language, the products I change in Indonesian did not change in English?

    please help


  35. Hello

    I am confused with this one.
    I use two languages in my web. English and Indonesian, but when I turn on the url friends, always appears a message like this

    This page is not available

    We’re sorry, but the Web address you’ve entered is no longer available.
    To find a product, please type its name in the field below.

    that is confusing is when I type a web url, by default that appears is or whether this is due to his .htaccess?

    what should i do?
    please help

    thank you

    1. Hello Ardhi,

      What CMS system are you using? Have you tried clearing your browsers cache after making the changes? Can you please provide your domain so we may see if we can troubleshoot further?

      Kindest Regards,
      TJ Edens

  36. Thanks for help,

    i have solved my problem.

    the server was locking my file so i deleted it and created it again and it works fine.

  37. but i am not able to do this …..This is my htaccess data i need to redirect to custom page #DirectorySlash Off


    #AddHandler application/x-httpd-php54 .php


    # File modified on Tue Mar 18 10:44:12 2014 by server

    # For security reasons, mod_php is not used on this server. Use a php.ini file for php directives

    # php_flag magic_quotes_gpc Off

    #php_flag register_globals Off


    # For security reasons, Option followsymlinks cannot be overridden.

    #Options -Indexes +FollowSymLinks

    # For security reasons, Option followsymlinks cannot be overridden.

    #Options -Indexes +FollowSymLinks 

    #RewriteCond %{QUERY_STRING} src=/~sbtester/images/uploads/

    #RewriteRule ^src=/~sbtester/images/uploads/$ src= [R=301]

    Options -Indexes +SymLinksIfOwnerMatch


    <IfModule mod_rewrite.c>

    RewriteEngine On


    RewriteCond %{HTTPS} on

    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


    RewriteCond %{QUERY_STRING} src=/images/uploads/(.*)

    RewriteRule ^phpthumb/phpThumb$ /$0?src= [L]


    RewriteCond %{REQUEST_URI} !^.*/serverReturns/.*\.php$

    RewriteCond %{REQUEST_URI} !^.*/cron/.*\.php$

    RewriteCond %{REQUEST_URI} !^.*/test\d*\.php$

    RewriteCond %{REQUEST_URI} !^.*/uploadify/.*$

    RewriteRule !\.(css|jpg|js|gif|png|ico|eot|woff|ttf|svg|swf|pdf)$ dispatch.php



    1. Hello Krish,

      Are you using any sort of content management system such as Joomla, WordPress, etc? If so, it is not likely possible to perform this as it will specifically need index.php.

      Kindest Regards,
      Scott M

  38. Thanks John for your fast reply,

    i have ensured that all settings of the homepage and the stores views asre set correctly, any other help?


    1. Hello Hamada,

      If your settings are correct and they’re not working when they once were, then you may need to contact Magento support for further assistance. It appears as the issue is more Magento oriented at this point and this may be something that they are required to address. Apologies that we cannot provide you a direct answer at this point.

      Arnel C.

  39. Hello ,

    i have some problem that may be ralated to this issue, i have changed the Directory Index for magento store since 4 months and it was working very well tell yesterday because of some one of the store managers have did some changes to the website configuration and it now it gave me “There was no Home CMS page configured or found.” and i don’t know what to do , i searched many time so please if you can help as my experience with Magento is something little.


    1. Hello Joe,

      Thank you for contacting us. I am not exactly sure what you are asking, but this guide lets you set which file will load when someone visits your website.


  40. does this mean i can edit the html file coz i dont want to edit the style.css coz am not yet good with css but html.

    1. Hello arthur,

      Thank you for contacting us today. This guide allows you to set which file will load when someone visits your website. For example, you can set it to load any of the following files: index.php, index.html, index.htm

      There are several ways to Edit Files, which are covered in our guide How do I edit a file on my server?

      If you have any further questions, feel free to post them below.

      Thank you,

  41. Thanks. I checked and all seems correct. Tried uploading Joomla also and still its not picking default page. So called the hosting support line and they admit that theres a fault at there end and they will fix it by eveving. Lets hope they fix it soon and then will try agin. Thanks for your replies.

    1. Be sure that the file name as well as the extension that you are referencing within your .htaccess file are exactly as they are on the server.

Was this article helpful? Join the conversation!