Serving Ionic WebApp from a subfolder

I generated a web version of my Ionic app using ionic build --prod, and then copied the www folder content to a subfolder called “appt” under the root of my Apache WebServer.

The app does not work because all references are set to /, so they resolve to http://myserver/ instead of http://myserver/appt.

After googling a while, I found the switches --base-href and --deploy-url, so now I am build the app using ionic build --prod --service-worker --base-href /appt --deploy-url /appt but problem persist, and the base tag remains as “/”.

The only workaround I’ve found is to manually edit the resulting index.html and manually adding the /appt part to all references, but obviously this is only a partial fix.

Am I missing something? For what I saw while googling, many people are facing this same problem.

1 Like

Look in angular.json for You should see stuff like "outputPath": "www". Next to it, add: "baseHref": "/appt".

Thanks! I will try this and let you know.

This suggestion is working after changing the angular.json as suggested by rapropos
All pages / urls are working from root but could not open a page with its specific url
say if I try to open by typing the url “” gives ‘Not found’ error message.
But the same page is opening from root ‘
Is there any solution to fix it to work all pages open with its own url
so, that we can refer a particular page to some one.

On my side the baseHref attribute from angular.json had no effect without a slash at the end of the subfolder string

"baseHref": "/appt" No effect

"baseHref": "/appt/" The application is served has expected from the subfolder