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...
You can also press "Ctrl-O" in your browser to open a file selection window. Navigate to the HTML file you wish to open and double-click it to you that file in your browser. Internet Explorer becomes your default browser when you install Windows. It will launch when you double-click an HTML file.
Just click Add Media and then Upload to upload your HTML file. Choose the HTML file you want to upload and then click Insert into post. Doing this inserts the link of the file into the post or page and automatically saves it to your Media Library.
To Open or Run an HTML file in Chrome Browser we need to Double click on that HTML file. It will Automatically will open in your Web Browser. If you file Isn't opening in your Browser, Then Right click on that HTML file and Select Open with option from there.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With