# Put an application in maintenance mode

You put an application in maintenance mode with a request-phase rule on its [rules engine](/en/documentation/platform/applications/rules-engine/). The rule answers every visitor with a maintenance page and ends the request before it reaches the origin. Removing the rule returns the application to normal, with no deploy. To change what visitors see when the origin itself returns an error, refer to [Custom Pages](/en/documentation/platform/workloads/#custom-pages).

---

## Prerequisites

- An application on Azion, bound to a workload.
- A maintenance page reachable by URL: a page on another site, or an object in an [Object Storage](/en/documentation/platform/object-storage/) bucket served by its own connector.
- Your public IP address, to keep your own access open.

---

## Redirect every visitor to the maintenance page

To send visitors to a page hosted elsewhere:

1. **Open the rules**

   Access [Azion Console](https://console.azion.com/) > **Applications** > **your application** > **Rules Engine** tab.

2. **Select Add Rule**

3. **Name the rule and select the phase**

   Enter a **Name**, for example `maintenance`, and select **Request Phase**.

4. **Set the criteria**

   In **Criteria**, set **If `${uri}` starts with `/`**, so the rule matches every request.

5. **Set the behavior**

   In **Behaviors**, select **Redirect To (302 Found)** and enter the URL of the maintenance page. The 302 tells browsers and search engines that the move is temporary.

6. **Select Save**

Every request to the application now answers with a 302 to the maintenance page, and nothing reaches the origin.

---

## Serve the maintenance page from your own domain

To keep visitors on your domain, serve the page from an Object Storage bucket instead of redirecting. **Rewrite Request** requires [Application Accelerator](/en/documentation/platform/applications/#application-accelerator) on the application.

1. **Upload the page to a bucket**

   For the steps, refer to [Upload and download objects](/en/documentation/guides/application-development/data/upload-and-download-objects-from-bucket/).

2. **Create a storage connector for the bucket**

   In **Connectors**, create a connector of type *Object Storage* that points at the bucket.

3. **Open the rules**

   Access [Azion Console](https://console.azion.com/) > **Applications** > **your application** > **Rules Engine** tab.

4. **Add a request-phase rule that matches every request**

   Select **Add Rule**, select **Request Phase**, and set **If `${uri}` starts with `/`** in **Criteria**.

5. **Set the behaviors**

   In **Behaviors**, add **Set Connector** with the storage connector, then **Rewrite Request** with `/maintenance.html`.

6. **Select Save**

Every request answers with the maintenance page from the bucket, under your own domain.

---

## Keep your own access open

To keep working on the application while visitors see the maintenance page, exclude your address from the rule:

1. **Open the maintenance rule**

   Access [Azion Console](https://console.azion.com/) > **Applications** > **your application** > **Rules Engine** tab, and select the rule.

2. **Add a condition**

   In **Criteria**, add **and** `${remote_addr}` **is not equal** your public IP address.

3. **Select Save**

Requests from your address reach the application as usual. Every other request still gets the maintenance page.

---

## End the maintenance

To return the application to normal, delete the maintenance rule. The remaining rules keep working as before.

---

## Next steps

- [Rules Engine](/en/documentation/platform/applications/rules-engine.md): Every criterion, operator, and behavior a rule can use.
- [Custom Pages](/en/documentation/platform/workloads.md#custom-pages): Replace the error responses of the origin with pages you control.
- [Minimize downtime](/en/documentation/fundamentals/minimize-downtime.md): Keep the application answering when an origin fails.
- [Test speed](/en/documentation/fundamentals/test-speed.md): Measure the application with real-user data and request metrics.
