NGINX and Angular 2

前端 未结 4 899
Happy的楠姐
Happy的楠姐 2020-12-05 11:06

My current app users routes like this /myapp/, /myapp//, /myaapp/dept/

My app is currently deployed in an internal http server with NGINX. The other server that acce

4条回答
  •  长情又很酷
    2020-12-05 11:09

    I had the same issue with a subdomain at a site hosted with HostGator shared hosting. It appears it's running Apache 2.2.31.

    Searching around eventually led me to "Apache Directives", which led me to "Custom Error Responses".

    I was able to fix my issue by creating a .htaccess file in my subdomain folder with the following line in it:

    ErrorDocument 404 /index.html
    

    Though looking at the debug tools, I'm still getting a 404 code returned even though it succeeds.

    UPDATE:

    Was able to fix the 404 issue by changing my .htaccess to the following:

    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
    

    Now I'm properly getting redirected to index.html and code is 200.

提交回复
热议问题