# Serving Ionic WebApp from a subfolder

**URL:** <https://forum.ionicframework.com/t/serving-ionic-webapp-from-a-subfolder/171192>\
**Category:** Ionic Framework\
**Created:** [August 14, 2019, 10:01pm UTC](https://forum.ionicframework.com/t/serving-ionic-webapp-from-a-subfolder/171192 "2019-08-14T22:01:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vespinasgmailcom](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vespinasgmailcom/32/127150_2.png) [@vespinasgmailcom](https://forum.ionicframework.com/u/vespinasgmailcom)\
**Post date:** [August 14, 2019, 10:01pm UTC](https://forum.ionicframework.com/t/serving-ionic-webapp-from-a-subfolder/171192/1 "2019-08-14T22:01:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [August 15, 2019, 3:18am UTC](https://forum.ionicframework.com/t/serving-ionic-webapp-from-a-subfolder/171192/2 "2019-08-15T03:18:55Z")

</div>

Look in `angular.json` for `projects.app.architect.build.options`. You should see stuff like `"outputPath": "www"`. Next to it, add: `"baseHref": "/appt"`.

---

<div class="post-metadata">

**Author:** ![vespinasgmailcom](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vespinasgmailcom/32/127150_2.png) [@vespinasgmailcom](https://forum.ionicframework.com/u/vespinasgmailcom)\
**Post date:** [August 15, 2019, 4:07am UTC](https://forum.ionicframework.com/t/serving-ionic-webapp-from-a-subfolder/171192/3 "2019-08-15T04:07:11Z")

</div>

Thanks! I will try this and let you know.

---

<div class="post-metadata">

**Author:** ![DrNVS](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/drnvs/32/14217_2.png) [@DrNVS](https://forum.ionicframework.com/u/DrNVS)\
**Post date:** [June 4, 2020, 3:58pm UTC](https://forum.ionicframework.com/t/serving-ionic-webapp-from-a-subfolder/171192/4 "2020-06-04T15:58:12Z")

</div>

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 “[www.mywebsite.com/contact](http://www.mywebsite.com/contact)” gives ‘Not found’ error message.  
But the same page is opening from root ‘[www.mywebsite.com](http://www.mywebsite.com)’  
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.  
thanks.

---

<div class="post-metadata">

**Author:** ![MathieuNa](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mathieuna/32/126368_2.png) [@MathieuNa](https://forum.ionicframework.com/u/MathieuNa)\
**Post date:** [July 2, 2020, 9:47am UTC](https://forum.ionicframework.com/t/serving-ionic-webapp-from-a-subfolder/171192/5 "2020-07-02T09:47:44Z")

</div>

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
