---
title: "Redirects, Password Protection & Maintenance Mode"
description: "Configure edge nginx HTTP redirects (301/302/307/308), HTTP Basic Auth password-protected directories, and HTTP 503 maintenance mode with IP bypass lists on Hosted EZ."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.hostedez.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Redirects, Password Protection & Maintenance Mode

Every Hosted EZ site—both **Static Sites** and **PHP/CMS sites**—includes nginx-enforced **Redirects**, **Password-Protected Directories**, and **Maintenance Mode** under **Site → Routing** in [app.hostedez.com](https://app.hostedez.com/dashboard). Because nginx evaluates these rules before PHP or static file handlers run, they add zero application overhead.

## Evaluation precedence order

When a request arrives at your site, nginx evaluates routing features in this exact order:

1. **ACME TLS validation (`/.well-known/acme-challenge/`)** — always allowed so certificate renewals never break, even during Maintenance Mode or site-wide password protection.
2. **Maintenance Mode** — returns HTTP `503` for all visitors whose IP is not in the bypass list.
3. **HTTP Redirects** — `exact` match rules are checked first, followed by `prefix` rules (longest prefix first), and finally a root `/` prefix redirect if configured. Redirects bypass HTTP Basic Auth.
4. **Password-Protected Directories** — enforces HTTP Basic Auth on matching paths (blocking direct static asset access under protected paths as well).
5. **Static Delivery / Application** — serves static files (with custom headers/SPA fallback/clean URLs) or proxies to Apache/PHP-FPM.

## HTTP Redirects

Open **Site → Routing → Redirects** to manage up to **`100` redirect rules per site**.

### Supported options

- **Source path**: site-relative path starting with `/` (max `512` bytes; trailing slash is normalized; `/.well-known/acme-challenge` is reserved).
- **Match type**:
- **`exact`**: matches only the exact path (for example, `/old-pricing` → `/pricing`).
- **`prefix`**: matches the path and everything beneath it, preserving the trailing path suffix onto the target URL (for example, `/blog` → `https://news.example.com/posts` redirects `/blog/launch` to `https://news.example.com/posts/launch`).
- **Target URL**: either a site-relative path starting with `/` or a full `http://` / `https://` URL (max `2,048` bytes).
- **Status code**:
- **`301`** — Moved Permanently (recommended for SEO migrations; cached by browsers)
- **`302`** — Found (Temporary redirect)
- **`307`** — Temporary Redirect (preserves HTTP method and request body, e.g. `POST`)
- **`308`** — Permanent Redirect (preserves HTTP method and request body)
- **Preserve query string**: appends the incoming query string (`?utm_source=...`) to the destination URL (merging cleanly with `&` if the target URL already contains a query string).
- **Enabled toggle**: disable a rule temporarily without deleting it.

## Password-Protected Directories (HTTP Basic Auth)

Open **Site → Routing → Password protection** to lock down `/` (your entire site) or specific subpaths (such as `/staging`, `/admin`, or `/internal-docs`) with HTTP Basic Auth.

### Limits & security behavior

- **Maximum rules per site**: `25` unique paths.
- **Realm**: `1–64` printable ASCII characters (displayed in the browser's sign-in prompt; default `Restricted Area`).
- **Username**: `1–64` characters matching `^[A-Za-z0-9._-]{1,64}$`.
- **Password**: `8–72` UTF-8 bytes; stored exclusively as a **bcrypt** hash (plaintext passwords are never persisted or echoed).
- **Automatic cache safety**: Any response served under a password-protected path automatically sets `Cache-Control: private, no-store` so shared proxies and CDNs never cache private pages or assets.
- **Static asset protection**: Subpath Basic Auth rules use nginx prefix matching (`^~`) so direct requests to `/private/report.pdf` or `/private/app.js` cannot bypass authentication.

> **Protect a preview or client review site**
>
> Add a Password-Protected Directory rule on path `/` to require credentials across the entire site while sharing work-in-progress designs with a client—without affecting automatic HTTPS certificate renewals.

## Maintenance Mode

Open **Site → Routing → Maintenance** to display a branded HTTP `503 Service Unavailable` page while performing major deployments, database imports, or content updates.

### Features & limits

- **HTTP status & headers**: Responds with HTTP **`503`**, `Retry-After: 300`, `Cache-Control: no-store, no-cache, must-revalidate`, and `CDN-Cache-Control: no-store` so search engines do not de-index your pages and caches do not store the maintenance notice.
- **Custom Title**: up to **`120`** characters (default: `Site under maintenance`).
- **Custom Message**: up to **`500`** characters (default: `We are performing scheduled maintenance and will be back shortly.`).
- **Bypass IPs / CIDRs**: up to **`20`** IPv4/IPv6 addresses or CIDR blocks (for example, `203.0.113.42` or `198.51.100.0/24`). Requests from allowlisted IPs bypass the `503` page and see the live site normally so you can verify changes before disabling Maintenance Mode.
- **Zero disruption to TLS**: `/.well-known/acme-challenge/` automatically bypasses Maintenance Mode.

## Testing routing rules from the CLI

```bash
# Inspect redirect status and Location header without following
curl -sI https://example.com/old-page | grep -iE '^(http|location)'

# Test a password-protected directory (expects 401 without creds, 200 with creds)
curl -sI https://example.com/private/
curl -sI -u "reviewer:your-password" https://example.com/private/

# Verify Maintenance Mode headers (expects 503 + Retry-After: 300)
curl -sI https://example.com/ | grep -iE '^(http|retry-after|cache-control|cdn-cache-control)'
```

Source: https://docs.hostedez.com/domains/redirects-auth-maintenance/index.mdx
