---
title: "Web server rules"
url: https://docs.corefinity.com/guides/sites/site-settings/web-server-rules
type: guide
last_updated: 2026-11-13
feature: nginx-rules
related:
  - https://docs.corefinity.com/api/reference/site-settings/get-nginx-policy.md
  - https://docs.corefinity.com/api/reference/site-settings/get-site-nginx-rules.md
  - https://docs.corefinity.com/api/reference/site-settings/replace-site-nginx-rules.md
  - https://docs.corefinity.com/api/reference/site-settings/get-site-backup-guard.md
  - https://docs.corefinity.com/api/reference/site-settings/update-site-backup-guard.md
  - https://docs.corefinity.com/api/reference/site-settings/copy-site-nginx-rules.md
  - https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_get.md
  - https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_validate.md
  - https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_update.md
  - https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_history_list.md
  - https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_revision_get.md
  - https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_revert.md
---
# Web server rules

Add your own nginx rules to a site, test them and save them.

## Before you start

- You can open the site in **Managed Websites**. Anyone who can open a site can change its rules.
- Each environment has its own rules: choose **Production** or **Staging** in the site header first.
- For a redirect, a password or a PHP setting, use [Redirects](/guides/sites/site-settings/redirects), **Password protection** or **Software & services** instead.

## Add a rule

1. **Open the site's rules**

   Go to **Managed Websites**, choose the site, then **Web server rules** under **Site settings**. A site with no rules reads **Not set**.

   _Screenshot: A site page with Web server rules ringed in the section menu. The card reads Not set, with the line Nothing set yet, and the buttons Start from a snippet, Convert an .htaccess… and Write rules._

2. **Start from a snippet, or write your own**

   Choose **Start from a snippet**, find one such as **Long-lived caching for static files** and choose **Insert at cursor**; or choose **Write rules** and type them. The tabs **Server**, **Headers**, **PHP** and **HTTP** hold the rules for each part of the configuration.

   _Screenshot: The rules editor, still reading Not set, with a snippet's lines on the Server tab, marked unsaved, and Save changes at the bottom. The Snippets panel on the right lists snippets, each with a button such as Insert at cursor, and Preview\._

3. **Test the rules**

   Choose **Test**: the rules are checked, then tried with this environment's own web server, and the result reads **Passed**. A problem is listed under **Problems** with its line.

   _Screenshot: The rules editor after Test: the steps Checking syntax, Checking policy and Testing with this environment's nginx, and the result Passed with the time it took._

4. **Review and save**

   Choose **Save**, and **Review and save** shows your change. Enter a **Note** for **History** if you want one, then choose **Save**.

   _Screenshot: The Review and save dialog for a site's first rules: the added lines, a Note box, Verify after Live with the path /cf-health, the Effect line Applies straight away, and the buttons Cancel, Test first and Save._

The rules apply straight away and the card reads **Live**. The site is then checked: if a check fails, your previous rules come back on their own and the card reads **Rolled back**.

_Screenshot: Web server rules after a save: the card reads Live, with the revision, who saved it and when. The Server tab holds the site's rules beside the Snippets panel, under the buttons Save and Test._

To bring the rules from an Apache host, see [Convert .htaccess](/guides/sites/site-settings/convert-htaccess).

To serve a folder or a second app under a path, see [Path apps](/guides/sites/site-settings/path-apps).

## Go back to earlier rules

1. **Open History**

   Open the section's **…** menu and choose **History**, where each save is a **Revision**. Choose one, then **Revert to this** and **Revert**.

   _Screenshot: The rules editor with the … menu open: History, Compare environments, Copy from another environment…, Explain a URL…, Convert .htaccess…, Verify paths…, Headers…, Add a rate limit…, Snippets and Download rules among its actions._

   _Screenshot: History in Web server rules: one row for each revision with when it was saved, by whom and its note, the newest marked Live and the earlier ones Applied, and Back to the editor._

A revert saves a new revision with the old content, tested first. The last 100 revisions of an environment are kept.

## Limits

- Each of the 4 tabs holds up to 64 KB, and an environment up to 200 locations. The meters above the editor show both.
- Some directives are refused, such as `listen`, `server_name`, `include` and `ssl_certificate`. **Problems** names the line.

## Automate this

**API:** [Replace a site's Nginx rules](https://docs.corefinity.com/api/reference/site-settings/replace-site-nginx-rules.md), scope `write`

```bash
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "WordPress admin under /wp/",
    "path_apps": [
      {
        "label": "Blog admin",
        "php": {
          "dir_index": [
            "wp-admin/"
          ],
          "entries": [
            "wp-admin/*.php",
            "wp-login.php"
          ],
          "router": [
            "wp-json/"
          ]
        },
        "prefix": "/wp/",
        "preset": "wordpress-admin",
        "root": "htdocs",
        "type": "php-app"
      }
    ],
    "version": 0
  }'
```

**MCP:** [`corestack_nginx_rules_update`](https://docs.corefinity.com/mcp/tools/corestack_nginx_rules_update.md), scope `write`

```json
{
  "name": "corestack_nginx_rules_update",
  "arguments": {
    "site_id": 4211,
    "version": 7,
    "content": {
      "server": "location /wp-content/uploads/private/ {\n    deny all;\n}\n"
    },
    "note": "Keep private uploads private"
  }
}
```

**Control Panel:** Managed Websites › your site › Site settings › Web server rules ([https://manage.corefinity.com/go/nginx-rules](https://manage.corefinity.com/go/nginx-rules))

## Related

- [Convert .htaccess](/guides/sites/site-settings/convert-htaccess): Turn an .htaccess file into rules.
- [Redirects](/guides/sites/site-settings/redirects): Send visitors from one path to another.
- [Error pages](/guides/sites/site-settings/error-and-maintenance-pages): Choose what visitors see on an error.
