# Subdirectory install

Quaeriva assumes no installation folder. Serving from `example.com/ask/` is one setting, not a template edit.

## Configure

```env
APP_BASE_URL=/ask
APP_URL=https://example.com
```

`APP_BASE_URL` is the path; `APP_URL` is the trusted public origin used for password-reset and verification links. Those links never trust the incoming `Host` header.

## What becomes base-path aware

Every page URL, asset URL, form action, redirect, canonical, sitemap entry, API prefix and admin URL. Nothing else needs editing.

## Rules for anyone writing code or a theme

- Build internal links with the URL helpers. Write paths without a leading slash (`'c/' . $slug`).
- Never hard-code a domain, a leading `/`, or the installation folder.
- Never hard-code `/admin` — the admin path is its own setting.
- The same rule applies to JavaScript: read the base path from what the server rendered rather than assuming `/`.

## Verifying

After deploying to a subdirectory, check:

- [ ] Home, question, topic, category, tag and profile pages load
- [ ] CSS, JavaScript, logo and favicon load — a missing asset usually means a hard-coded `/`
- [ ] Sign-in, sign-out and password reset work, and the reset link points at the right origin
- [ ] The admin panel loads at `{base}/{admin_path}` and every form posts back correctly
- [ ] `{base}/sitemap.xml` lists URLs that all include the base path
- [ ] Canonical tags include the base path

## Common mistakes

| Symptom | Cause |
|---|---|
| Unstyled site | An asset URL hard-coded a leading `/` |
| 404 on every internal link | A link built without the URL helper |
| Reset email points at the wrong host | `APP_URL` not set, or set to the wrong origin |
| Admin loads but forms 404 | A form action hard-coded `/admin` |

## Moving between root and subdirectory

Change the setting and clear any cached page copies. Content is unaffected — URLs are generated at render time, not stored. If you are also changing the domain, see [Move domain](../09-recipes/MOVE-DOMAIN.md).
