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.
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
- Log into your cPanel.
- Find the Files category and click on the File Manager icon.
- Click Settings at the top right corner.
- 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.
- Look for the .htaccess file and right click on it. This brings up a menu. Find and click on the Edit option.
- You may be presented with a popup. Click on the Edit button.
- 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
- Be sure to hit the Save Changes button in the upper right corner to save your new htaccess configuration.
My in my website subdomains redirects to main domain 404 the website is in php how can i fix it please
Check that you do not have a redirect setup to go from your subdomain to the main domain. For example there may be a 301 redirect setup in cPanel or directly in your .htaccess file.
Thank you so much.It worked for me, I wish best for all.
You’re welcome. Glad to hear that it helped!
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
Try the Insert Headers and Footers WordPress plugin.
My website running on website.com/index.php but showing error on website.com/index.html How can I resolve this issue as I read your article and did the things you mentioned above but not working for me.
What troubleshooting steps have you taken so far?
Thank you.
It took the server about 6 hours to clear its cache, but it finally worked then.
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
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,
John-Paul
I loaded up only my WordPress CMS Blog Website to domain example.com and want the domain to default to https://example.com/website/ which is where my CMS Blog Website resides.
In which file would I insert the following?
RewriteCond %{HTTPS_HOST} ^example.com
RewriteRule ^(.*) https://example.com/website [P]
or?
define(‘WP_HOME’,’https://example.com’);
define(‘WP_SITEURL’,’https://example.com/website’);
Please help because I want the example.com to open
https://example.com/website/ all the times – default.
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.
How do I replace the default HOME page from CodeIgniter to the HOME Page of WordPress (rest other pages will stay in CodeIgniter) ?
https://stackoverflow.com/questions/52294558/how-to-replace-home-page-from-codeigniter-to-home-page-of-wordpress-other-pages
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.
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.
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
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
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.
How can i add a logo to my coming soon page
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.
how i can change the .httaccess file of my site thepinoychannel.me
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.
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?
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.
Great!
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.
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/newdomain.com then you would need to create /home/userna05/newdomain.com/.htaccess
Thank you so much. I have successfully put my site in under construction status…
Can I redirect to an “under construction” page?
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.
Thi is ok. But it is good if there is now option under cPanel to Suspend each (addon) domain.
Didn’t work. Still gives me a directory listing instead.
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.
Javacoders, we’re glad that this was helpful to you!
Very helpful. Thank you 🙂
Superb….!!!!! (y)
I bookmarked this page 🙂
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
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.
Regards,
Arnel C.
This guide was sick. Worked instantly, thanks so much!
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
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.
Thank You! Finally, easy to understand and implement. Excellent for those of us that do not use or understand code.
very helpful…Thanks
Very helpful !!!
You really saved my ass. Thank You so much for this wonderful guide!
Very very helpful. Thanks so much!
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.
Thanks!
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,
John-Paul
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=”…….”
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
Ok! Thanks 🙂
very very thanks
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.
Hello rupak, what is the name of the default page?
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 knowHello 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
Thankyou! it worked right away 😀
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?
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.
Sir my 2 pages this link
www.domain.com/female.php?name=riya
www.domain.com/male.php?name=ajay
I want to this like url
www.domain.com/riya
www.domain.com/ajay
how to using .htaccess code please give me help
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
The workaround to this is just to set the WP “site URL” to https://domain.com/index.php in general settings. Then set it back to just the domain and deprioritize the html index priority in .htaccess to launch.
Cheers!
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.
Regards,
Arnel C.
there are no .htaccess on my server for me to edit the file..my website is not displaying,i dont know what the problem is….i need some help
I guess the only trouble I have in testing this is that the wordpress home page can’t be reached by simply typing in domain.com/index.php (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.
Wow! This was simply amazing
-SAM
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.
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: https://documentation.cpanel.net/display/ALD/DirectoryIndex+Priority
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.
THX!
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
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.
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 mydomain.com/shop.
Best Regards,
TJ Edens
thanks you help me alot
Thanks its working
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
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,
John-Paul
I’ve changed this file to redirect me to the blog, but now I want the default file. where can I get it?
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 ,
John-Paul
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.
Hello Dan,
Yes, just put the folder name in the front of the file name “folder/index.html” for instance.
Kindest Regards,
Scott M
Thank You
Kind Regards
Sushant
Thank you so much, this post helped me a lot
Thanks for the infor Team.
Kind Regards
john
Exactly what I was looking for, sweetheart 🙂
Thank you so much, this post helped me a lot.
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 displaying.am confused here.can some one help me out
Unable to open WampServer’s config file, please change path in index.php file
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
HI. How To set The default URL for same page in my Website..
Like., My website is www.mahindracarspares.com ., and I want to set the default URL is www.mahindracarspare.com in every pages of my websites .. So How can I do This ??
Hello Abhay,
Your best bet would be to put a 301 redirect in your .htaccess as in the example below:
RewriteCond %{HTTP_HOST} ^DomainA.com
RewriteRule ^(.*) https://DomainB.com/$1 [P]
Best Regards,
TJ Edens
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
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.
Regards,
Arnel C.
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 🙁
Regards
Nimantha
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
This is the second htaccess- file coding
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
Hello Shane,
You will want to check out our article on 301 redirects for the correct format for your situation.
Kindest Regards,
Scott M
my weblink is ecommerce.capixatech.in
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
Thank you for this information.
how to do my login page is default index page and after that open home page of my shop
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,
John-Paul
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.
Thanks
Arun
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.
Regards,
Arnel C.
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.
Regards,
Arnel C.
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
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?
www.indoislamicpedia.com
please help
regards,
Ardhi
Hello Ardhi,
The files permissions for the .htaccess file should be 644. Here is a guide on adding other languages to prestashop.
Kindest Regards,
TJ Edens
How can a user set the server to automatically open his wordpress home page after immediately installing it?
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 www.mydomain.com/ID/page-not-found or www.mydomain.com/en/page-not-found. whether this is due to his .htaccess?
what should i do?
please help
thank you
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
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.
Ur going well the article with screenshot and written steps helps to understand easily.Thanku..
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=https://60.195.124.171/~sbtester/images/uploads/ [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=https://www.sbtester.com/images/uploads/%1 [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
</IfModule>
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
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?
Thanks
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.
Regards,
Arnel C.
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.
thanks
Hello Hamada,
Thank you for contacting us regarding Magento. First, make sure you have the Magento Home page setup correctly in the Dashboard.
Also, make sure your Store View is enabled, this should allow it to display.
Thank you,
John-Paul
Its the same way to add a new index?
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.
Thanks,
John-Paul
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.
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,
John-Paul
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.
Didnt worked for me.
getting
Not Found
The requested URL was not found on this server.
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.
THANK YOU!!!
It is excellent as it is.
this is the simple & best method that anybody can understand.just keep it SIMPLE..all the very best.
thanks, very useful
Thanks. Just what I was looking for.
Thanks
Wonderful