1

I used a free domain hosting service with their extension suffixed to my website. When I tried to look at the site on a browser, I get a 404 error unless I add a / at the end of .com suffix (or) explicitly hardcode .com/index.html the site shows a 404 error.

Why is my website giving a 404 error? Should I do a mapping or something special to make it look at the index.html file in the public_html folder by default?

I used FireFTP to upload the HTML, CSS, JS and jQuery files to the domain.

1 Answer 1

4

Some hostings might not have mapping for default file to be used as homepage, thus you might sometimes need to add it.

If this is Apache-based hosting(commonly Linux hostings use Apache), you will want to create/add new line to .htaccess file like so:

.htaccess file:

DirectoryIndex index.html

If it's Windows-based hosting running IIS, check how to set default directory index here.

web.config file:

<?xml version="1.0"?>
<configuration>
   <system.webServer>
      <defaultDocument enabled="true">    <!-- this line enables default documents for a directory -->
         <files>      
            <clear/>     <!-- removes the existing default document list -->                
            <add value="foo.htm"/>     <!-- foo.htm is now the default document  -->                
            <add value="foo.php"/>     <!-- 2nd default document in search order -->                
            <add value="foo.aspx/>     <!-- 3rd default document in search order -->                
            <add value="foo.cfm/>      <!-- 4th default document in search order -->
         </files>
      </defaultDocument>
      <modules runAllManagedModulesForAllRequests="true"/>
   </system.webServer>
</configuration>
3
  • wrong: .htaccess is not for Linux hosting, it is for Linux hosting with Apache. lighttpd is a web server running on Linux and does not use .htaccess
    – Basile Starynkevitch
    Jul 17, 2015 at 22:46
  • 1
    Corrected -----
    – Alexus
    Jul 17, 2015 at 22:51
  • 1
    Correction: it is for hosting with Apache.. The same applies to Apache running under Windows.
    – tkausl
    Jul 18, 2015 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy