If your angular application working well on localhost then does not work on linux host when redirecting any of existing page with returning 404 error. It means that you have missing routing configuration for routing.
To provide right configuration on linux apache server just put following code to .htAccess file of your angular application root folder and check the the magic :)
.htaccess file content should be as 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]
On the otherhand, If you deployed your app to another servers check the following solutions :
IIS Server on windows host , following webconfig rule can be help you to solve your redirection problem
web.config file content should be as following;
For more information about this issue, just check the offical page from this link : https://angular.io/guide/deployment
To provide right configuration on linux apache server just put following code to .htAccess file of your angular application root folder and check the the magic :)
.htaccess file content should be as 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
On the otherhand, If you deployed your app to another servers check the following solutions :
IIS Server on windows host , following webconfig rule can be help you to solve your redirection problem
web.config file content should be as following;
- <system.webServer>
- <rewrite>
- <rules>
- <rule name="Angular Routes" stopProcessing="true">
- <match url=".*" />
- <conditions logicalGrouping="MatchAll">
- <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
- <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
- </conditions>
- <action type="Rewrite" url="/index.html" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
For more information about this issue, just check the offical page from this link : https://angular.io/guide/deployment