
.htaccess Editor API
Free .htaccess editor with AI assistance. Create and modify Apache server configurations using plain English.
Send your API key in the Authorization header as a Bearer token (Authorization: Bearer YOUR_API_KEY) or in the X-API-Key header.
10 requests per minute
1 endpoint available
Overview
Describe what you want in plain language and get back .htaccess content. Send your existing file as currentHtaccess to have the change applied to it (keeping the rest), or leave it out to get a new file.
Notes
instructionis up to 5,000 characters;currentHtaccessis up to 50,000.modeis"edit"whencurrentHtaccesshad content and"create"otherwise.- Test the result on a staging server first. A bad .htaccess can take a site down with a 500 error.
This endpoint calls an AI model, so it uses the AI rate limit: 10 requests per minute and 200 requests per day per API key. Output is generated by a model and can be wrong, so review it before you use it.
Endpoints
https://opentools.ca/api/v1/tools/htaccess-editorRequest Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| instruction | string | Required | What the file should do, or what to change, e.g. "redirect all HTTP traffic to HTTPS". 1-5,000 characters. |
| currentHtaccess | string | Optional | Existing .htaccess content to edit. Omit or leave blank to create a new file. Up to 50,000 characters. |
Response Example
{
"success": true,
"mode": "edit",
"htaccess": "ErrorDocument 404 /404.html\n\nRewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]"
}Error Codes
Code Examples
curl -X POST https://opentools.ca/api/v1/tools/htaccess-editor \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"instruction": "Redirect all HTTP traffic to HTTPS",
"currentHtaccess": "ErrorDocument 404 /404.html"
}'Rather use it in your browser? Open the .htaccess Editor