Ionic 4 - Build for browser

#1

I want to run the app on a web server ( static files hosting ) and having a problem.

Assume the app runs with domain www.example.com and inside it routes to different pages let’s say example.com/products, the issue if the user refreshes the browser then it would fail to load because the web server would try to open the folder ‘products’ in the root directory.

Command to build:
ionic cordova build browser

@ionic/angular": "^4.0.0-rc.0

thanks

#2
ionic cordova platform add browser
ionic cordova build browser --prod
#3

Already added ‘browser’ platform, and building in production for sure is not the cause.

#4

add following code in your .htaccess file
.htaccess

RewriteEngine on
# Don’t rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow HTML5 state links
RewriteRule ^ index.html [L]