0

I've been working on a ASP.NET web application project in Visual Studio. In that project, when the user enters the hostname they get a 404 error but what I would like to happen is for them to be redirected to the index.html when they have just entered the hostname.

I was wondering how this is done. Below is the code that I used but it didn't work

<location path="">
   <system.webServer>
      <httpRedirect enabled="true" destination="../index.html" httpResponseStatus="Permanent" />
   </system.webServer>
 </location>
LM2016
  • 43
  • 8

1 Answers1

0

You can use .htaccess file to redirect 404 to another page. Check the answer in this post: How do I redirect 404's to index.html and rewrite the URL to the home page URL?

ahmetcetin
  • 2,621
  • 1
  • 22
  • 38
  • 1
    Thanks, I'm relatively new to this so having a little bit of difficulty. I don't know where I would find the .htaccess file – LM2016 Jun 30 '17 at 11:09
  • `.htaccess` should live in the root folder of your public www directory...if there's not one, I believe you can just create one...note that the `.` ensures that the file is hidden, so you may have the file but just make sure hidden files are showing, or use the `ls -a` command in terminal to show hidden files... – twknab Jun 30 '17 at 11:16
  • 1
    .htaccess file is a configuration file of Apache. You can find how and when to use .htaccess file here: https://httpd.apache.org/docs/current/howto/htaccess.html – ahmetcetin Jun 30 '17 at 11:16
  • Why do you guys assume he's running Apache? – HaukurHaf Jun 30 '17 at 11:22
  • **she's. After some research I think I need to put the redirect into the web.config file... it's an ASP.NET web application – LM2016 Jun 30 '17 at 11:32
  • No you dont. Whats yhe name of the html file you want to be shown by default? – HaukurHaf Jun 30 '17 at 18:57
  • It's index.html – LM2016 Jul 04 '17 at 08:45