I just hosted a website. But, when i want to run the website it opens the index of the website (list of files what i added using FTP and not the Index.html page). How to fix that?
Please help...
I just hosted a website. But, when i want to run the website it opens the index of the website (list of files what i added using FTP and not the Index.html page). How to fix that?
Please help...
If you want to display the contents of an index.html file when a request is made to your website domain, let's say it is domain.com, then all you have to do is to upload the index.html file to the correct document root directory on your server.
The document root is the folder where the website files for a domain name are stored.
Document root directories might be named differently depending on your server configuration, however, they're conventionally named as such:
/www/
/public_html/
They also might live within another directory such as
/home/myusername/public_html/
Your primary domain is generally rooted in the www or public_html folder.
When someone tries to load your website and does not manually type in a file name (such as index.php or index.html), the server attempts to load the "directory index". The directory index is a listing of files it should load.
For example, if you type in domain.com (i.e: not domain.com/index.php), the server will attempt to load files in the following order. If a file is not found, then it tries to load the next file in the list:
http://domain.com/index.html
http://domain.com/index.htm
http://domain.com/index.php
...and finally, if your server does not find any of these files, it then simply returns a listing of all of the files in the directory. See Image
To prevent this, one should create an index.html file and upload it to the server's document root directory as we mentioned before.
Try creating your first .html file with a simple text editor by copying the html markup below into a new file and then save it as index.html or download the file here
<html>
<head>
<title>My website's first HTML5 page</title>
</head>
<body>
<h1>Welcome!</h1>
<p>Sorry, but our website is under development.</p>
</body>
</html>
Proceed and upload the index.html file to your server's document root directory, and then try to access your website domain. It will probably load your index.html and your server will now display the contents of index.html file instead of the "DirectoryIndex listing of files".
WHEN IT DOES NOT WORK:
If you've just placed an index.html or index.php file on your server's document root folder, for example: /public_html/ and you're still not getting it to load these files upon a request to your domain, chances are your server is missing a specific configuration for the "DirectoryIndex Directive".
If that fails to happen, you can use the DirectoryIndex directive in an .htaccess file to specify a custom file or files that the web server looks for when a visitor requests a directory. To enable the DirectoryIndex directive, use a text editor to create/modify the .htaccess file as follows. Replace filename with the file that you want to display whenever a user requests the server's document root directory:
DirectoryIndex filename
You can also specify multiple filenames, and the web server will search for each file until it finds a match.
Open a text editor and copy the following example directive, then paste it on the new file:
DirectoryIndex index.php index.html index.htm
Save the file as .htaccess
No file extension, just name it as .htaccess placing a dot (.) in front of it to ensure it is a hidden file.
In this directive, when a visitor requests the directory name, the web server looks first for an index.php file. If it does not find an index.php file, it looks for an index.html file, and so on until it finds a match or runs out of files to search.
Now upload the .htaccess file to your server's document root directory.
It is recommended to restart the server in order to changes to take effect, although you could just try to refresh the directory to see if it works.
If you've got full control over your server you might find it easy restart/reload it. However, if you rely on a shared hosting service, maybe you'll not have enough permission to create an .htaccess file or to restart the server on your own, meaning that you would have to contact your hosting provider support team and request them to do that for you.
I hope it helps you. Good luck.
Your question is highly confusing. Did you mean your website is opening index.html page on loading? or did you mean it is not loading index.html page. I will try to answer but you need to provide more information. If you type the link and index.html is opening than it is working correct because it will always open index file as homepage unless you have specified something else. secondly make sure you have uploaded all the files in correct folder because it is usual that when a user is inexperienced ftp could be confusing. So check it and add more details if possible.
The following could also be the reason for the same problem(In your case its not) as you mentioned and I am providing this for all New Learners who face such problems. if your website is hosted on IIS then you'll need to add the default Document. TO add this=>
Double click on Default Documents icon in IIS, then if you don't see the index.html/php page then right click there and select Add and Type your index page name with extension and Click OK. Check your site in Browser.
All you have to do is rename the home page as index.html that's it, it will automatically page stats running.
I felt so dumb when I ran into this issue the first time when trying to do something similar. Just run the index.html file directly, assuming everything was previously configured properly.
You can either do that by directly using the file with say, Finder on Mac or File Explorer on Windows, or you can paste in the filesystem address right into the browser!
So if you're on say, Safari on a Mac, you'd plug this into your address bar:
file:///Users/username/repos/project_name/index.html
And Bob's your uncle! ;)