node.jsangularhostingweb-hostinggodaddy-api

Accessing specific URL throws 404 error for website hosted on GoDaddy


I have a angular7/mysql/node.js website hosted on GoDaddy and I'm facing following issue.

When I access website using base URL like www.abcdef.com, it opens home page and then using links provided on home page to go to other pages like About Us, Contact Us, etc. I can access those pages. But if I try to access a page using specific URL like www.abcdef.com/aboutus, website throws an 404 error and I'm redirected to error page.

I'm new to hosting and stuff so any help would be greatly appreciated.

Thanks


Solution

  • Have you configured your server to redirect requests to missing files to index.html?

    See https://angular.io/guide/deployment#server-configuration. I'm not familiar with GoDaddy hosting, but I'm guessing you should add the .htaccess file (create/edit the .htaccess file in the root folder):

      RewriteEngine On 
      # If an existing asset or directory is requested go to it as it is 
      RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] 
      RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d 
      RewriteRule ^ - [L] 
     
      # If the requested resource doesn't exist, use index.html 
      RewriteRule ^ /index.html