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.
On this page
Start it
Paste this into an assistant that is connected to Corefinity.
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
.htaccessfile: read it with your own access to the old host, or ask the person to paste it. - Never put credentials or
SetEnvvalues 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
- Read the file from the old host, and the site's current rules with
corestack_nginx_rules_get. - Convert it with
corestack_nginx_htaccess_convert. Read what it converted, what it left out and why. - Redirects: add the redirect lines through
corestack_redirects_import, then save them withcorestack_redirects_update. Redirects never go into nginx rules. - Validate the converted rules with
corestack_nginx_rules_validate, and fix what it reports until it passes. - Save with
corestack_nginx_rules_update, with/and two key pages of the site asverify_paths, once the person agrees. Follow the task it answers. - Check with
corestack_nginx_rules_explainandcorestack_site_http_checkon 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
SetEnvvalue: 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?