CorefinityCorefinityDocs
Open the Control PanelControl Panel
Playbooks · 11 of 13

Convert an .htaccess file into nginx rules

Turn an Apache .htaccess file from the old host into redirects and validated nginx rules for a site, check them, and save them once the person agrees.

convert-htaccess
On this page

Start it

Paste this into an assistant that is connected to Corefinity.

Prompt
Use the Corefinity MCP prompt "convert-htaccess" with site: <the site: its domain, or the id of any of its environments>, environment: <the environment's name, for example staging. without it the prompt works on production when this token may, otherwise on the first environment it may>. Follow it step by step and tell me before anything that changes my account.

Arguments

siteRequired

The site: its domain, or the id of any of its environments.

environment

The environment's name, for example Staging. Without it the prompt works on production when this token may, otherwise on the first environment it may.

What your assistant is told

Purpose: carry what an Apache .htaccess file did on the old host over to <the site's domain>: its redirects into the Redirects tools, and the rest into nginx rules that pass the platform's checks.

Before you start

  • The row you work on is site row <the id of the site row you work on> (<the environment's name>). Use it as site_id.
  • You need the old host's .htaccess file: read it with your own access to the old host, or ask the person to paste it.
  • Never put credentials or SetEnv values into rules: a value the application needs goes into its environment, a password into HTTP auth (corestack_http_auth_update).
  • Ask before every change, and type a confirm_* value only after the person has said yes to that exact action.
  • If a call is refused because this token lacks a scope or the site is outside its limits, the person is asked to allow it in the Control Panel; carry on once they have.

Steps

  1. Read the file from the old host, and the site's current rules with corestack_nginx_rules_get.
  2. Convert it with corestack_nginx_htaccess_convert. Read what it converted, what it left out and why.
  3. Redirects: add the redirect lines through corestack_redirects_import, then save them with corestack_redirects_update. Redirects never go into nginx rules.
  4. Validate the converted rules with corestack_nginx_rules_validate, and fix what it reports until it passes.
  5. Save with corestack_nginx_rules_update, with / and two key pages of the site as verify_paths, once the person agrees. Follow the task it answers.
  6. Check with corestack_nginx_rules_explain and corestack_site_http_check on the paths the rules affect.

Stop and ask

  • Before saving rules or redirects, and before saving on production.
  • When the file sets a credential or a SetEnv value: leave it out and tell the person where it belongs instead.
  • When validation still fails after two rounds of fixes: stop and show the person what it reports.

When you are done

Report the redirects added, the rules saved and what each does, what was left out of the conversion and why, and the checks' results.

Was this helpful?
Open in ClaudeOpen in ChatGPT