.htaccess Editor

.htaccess Editor API

Web Development

Free .htaccess editor with AI assistance. Create and modify Apache server configurations using plain English.

Authentication

Send your API key in the Authorization header as a Bearer token (Authorization: Bearer YOUR_API_KEY) or in the X-API-Key header.

Rate Limit

10 requests per minute

Endpoints

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

  • instruction is up to 5,000 characters; currentHtaccess is up to 50,000.
  • mode is "edit" when currentHtaccess had 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

POST
https://opentools.ca/api/v1/tools/htaccess-editor
Create or edit an Apache .htaccess file

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
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
OptionalExisting .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

400
Invalid JSON or a field failed validation (missing, empty, too long, or not an allowed value). details lists each problem.
401
Missing or invalid API key
403
API key is inactive or expired, or the request IP is not allowed for this key
429
Rate limit exceeded (10 per minute or 200 per day per key)
500
Internal server error, including a failed AI model call

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"
  }'

Ready to get started?

Create an API key to start using the .htaccess Editor API.

Rather use it in your browser? Open the .htaccess Editor