Skip to content

Where to put a redirect on cPanel — UI, .htaccess, or vhost include

A decision tree for picking between the cPanel Redirects UI, .htaccess, and the Apache Include Editor for HTTP redirects, with the latency, audit, and persistence trade-offs made explicit.

cPanel exposes three different places to define a redirect. The cPanel Redirects UI under cPanel > Domains > Redirects writes to the user’s .htaccess. A .htaccess Redirect or RewriteRule directly does the same. The WHM Include Editor at the vhost level writes to a config file Apache parses once at startup. They all “work” — but they have different performance, audit, and persistence properties. Picking the right one matters more than people think.

What’s happening

.htaccess is parsed at every request, in every directory walked from the docroot down to the requested file. A redirect there is evaluated on the request path. A redirect in the vhost config is parsed once at Apache load and stored in memory; matching is faster but the operator needs WHM access to change it. The cPanel UI is .htaccess with a UI wrapper. None of them differ in HTTP status code — all can return 301 or 302 — but they differ in who can change them, how visible they are to audit, and how much per-request latency they add.

How to verify

For a domain, see every redirect in play:

grep -nE "Redirect|RewriteRule" /home/<user>/public_html/.htaccess
apachectl -t -D DUMP_INCLUDES | grep -A5 example.com | grep -iE "redirect|rewrite"
whmapi1 redirect_list account=<user>
curl -sI https://example.com/old-path | head

The first command shows .htaccess-level redirects. The second shows include-level. The third is the cPanel UI-managed list.

The fix

The decision tree:

  1. Customer manages the redirect themselves → cPanel Redirects UI. The customer can add, change, remove without touching files. cPanel writes to .htaccess; the change is visible to your audit grep.
  2. Customer’s developer manages it via deployment → .htaccess directly. The developer’s deploy includes the file; the change is in version control on their side.
  3. You manage it as part of the hosting setup (a domain alias, a www-to-non-www redirect, an HTTPS-everywhere policy) → WHM > Apache Configuration > Include Editor > Pre VirtualHost Include scoped to the vhost. The redirect lives in cPanel-managed config that persists across rebuilds and is not in the customer’s tree.
  4. Performance-sensitive redirect (every request hits it) → vhost include, not .htaccess. The difference is parsing cost per request.
  5. Audit-sensitive redirect (compliance, traffic engineering, must be visible to ops) → vhost include. .htaccess is in the customer’s tree and they can change it without you knowing.
  6. Temporary redirect during a migration → vhost include, with a comment containing the ticket number and the expected removal date. Schedule a calendar reminder to remove it.

Apply the rule, run apachectl -t && apachectl graceful for any vhost-include change, and validate with curl -sI against the source URL.

For environments where redirects multiply faster than they get cleaned up, Stack Harbor audits the redirect chain quarterly under managed cPanel operations.