skip to Main Content

I have created an Angular application and it is working fine. If I try to access a specific page on the browser I can type the route and it will redirect me there. Now the backend shares this route in mail and I would like to redirect to this page.

Accessing the page however, throws 404 error.

I am using cPanel as my hosting service.

Any help would really appreciate. Been trying it for days now.

I have tried changing .htaccess to have RewriteEngine On but still not working as expected.

2

Answers


  1. Check your Nginx configuration file. It should be similar to:

    server{
        listen 80;
        listen [::] 80;
        server_name www.example.com example.com;
        root /var/www/example.com;
        index index.html;
        location / {
            try_files $uri$args $uri$args/ /index.html;
        }
    }
    

    Updated:

    I have never tried that, but something similar to nginx config above but for .htaccess is:

        <IfModule mod_rewrite.c>
          RewriteEngine on
          RewriteCond %{REQUEST_FILENAME} -s [OR]
          RewriteCond %{REQUEST_FILENAME} -l [OR]
          RewriteCond %{REQUEST_FILENAME} -d
          RewriteRule ^.*$ - [NC,L]
          RewriteRule ^(.*) /index.html [NC,L]
       </IfModule>
    
    Login or Signup to reply.
  2. Add a rewrite rule to the .htaccess as below.

    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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search