---
title: "corestack_nginx_htaccess_convert"
url: https://docs.corefinity.com/mcp/tools/corestack_nginx_htaccess_convert
type: tool
last_updated: 2026-11-13
feature: nginx-rules
related:
  - https://docs.corefinity.com/api/reference/site-settings/create-site-htaccess-conversion.md
  - https://docs.corefinity.com/guides/sites/site-settings/web-server-rules.md
---
# corestack_nginx_htaccess_convert

**Convert .htaccess to nginx rules.** Convert an Apache .htaccess file into nginx rules for an environment row. The table-driven part is converted at once; lines it cannot convert are sent, redacted, to an AI model for suggestions to review. Nothing is saved: put the result through corestack_nginx_rules_validate and corestack_nginx_rules_update, and the redirect lines through corestack_redirects_import. 20 conversions an hour per person. Scope: read. Long-running: answers with a task.

- Scope: `read`
- Runs as a task: yes

## When to use it

Convert an Apache .htaccess file into nginx rules for an environment row. The table-driven part is converted at once; lines it cannot convert are sent, redacted, to an AI model for suggestions to review. Nothing is saved: put the result through corestack_nginx_rules_validate and corestack_nginx_rules_update, and the redirect lines through corestack_redirects_import. 20 conversions an hour per person.

The task completes with `conversion`: the rules per hook with their source lines, the Apache redirect lines, the lines the platform already handles, pointers to other settings, the unconverted lines, and `ai.status` (`not_needed`, `running`, `done`, `failed` or `disabled`). An AI failure still completes with the deterministic part. Follow the task with corestack_task_get.

## Inputs

- `site_id` (integer, ≥ 1, required): The environment row the rules are for (its platform and hooks).
- `content` (string, required): The .htaccess text, at most 256 KB.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "content": {
      "description": "The .htaccess text, at most 256 KB.",
      "maxLength": 262144,
      "minLength": 1,
      "type": "string"
    },
    "site_id": {
      "description": "The environment row the rules are for (its platform and hooks).",
      "minimum": 1,
      "type": "integer"
    }
  },
  "required": [
    "site_id",
    "content"
  ],
  "type": "object"
}
```

## Refusals

- `too_large`: the file is over 256 KB; convert it in parts.
- `work_failed` (in the task's result, `details.reason` `conversion_expired`): the conversion expired before it was read; convert the file again.
- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_nginx_htaccess_convert",
  "arguments": {
    "site_id": 4211,
    "content": "Redirect 301 /old /new\nRewriteEngine On\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule ^ index.php [L]\n"
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_nginx_htaccess_convert with site_id 4211, content Redirect 301 /old /new
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
. (Convert .htaccess to nginx rules.) Tell me what it returned.
```

## The same task elsewhere

- Endpoint: [POST /api/corestack/sites/{site}/nginx-rules/htaccess](https://docs.corefinity.com/api/reference/site-settings/create-site-htaccess-conversion.md)
- Guide: [Web server rules](https://docs.corefinity.com/guides/sites/site-settings/web-server-rules.md)
