Format: Mastery Session, teacher-led, about 60 minutes plus a 10-minute lab.
Audience: Customer Success specialists working with managed hosting (mostly WordPress).
.htaccess, hPanel settings) and what belongs to sysadmins (server config, restarts)..htaccess file and spot what does not belong there..htaccess safely: back up, change one thing, test, roll back..htaccess..htaccess and understands mod_rewrite rules. Everything in this session applies to it.server: LiteSpeed). With a CDN or Cloudflare in front, the header may show the proxy instead..htaccess still works there through an integration built by our team, but for WordPress sites only.| We can do | Sysadmins only | Customer / developer |
|---|---|---|
Read and troubleshoot .htaccess, check logs, change PHP options in hPanel, run read-only checks over SSH |
Main server config (httpd.conf, virtual hosts), AllowOverride, ServerTokens, timeouts, service restarts |
Writing custom rewrite logic for their project, plugin updates, code fixes |
AllowOverride, ServerTokens and Timeout only work in the main server config. Inside .htaccess they are ignored or cause a 500. If a customer pastes them from a tutorial, that is often the cause.
The default block that WordPress writes when permalinks are saved:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
!-f) or folder (!-d), send it to index.php and stop ([L]).# BEGIN WordPress and # END WordPress. Custom rules go outside the markers.index.php. Put redirects above it.# BEGIN … # END blocks. Note which plugin owns which block before touching anything.RewriteBase /subfolder/ and /subfolder/index.php. Multisite uses a different block.| Flag | Meaning |
|---|---|
[L] | Last: stop processing further rules in this pass. |
[R=301] / [R=302] | External redirect, permanent or temporary. Test with 302 first: browsers cache 301s. |
[NC] | No case: match is case-insensitive. |
[QSA] | Keep the query string (?utm=…) when the rule adds its own. |
# php -- BEGIN cPanel-generated handler or AddHandler application/x-httpd-ea-php…. They can force a wrong PHP version, cause a 500, or make the browser download PHP files instead of running them.php_value / php_flag lines. Prefer hPanel's PHP Configuration; old lines here can conflict with it..htaccess.bak-YYYYMMDD in File Manager or over SSH.configtest for .htaccess: the next request is the test. Check with curl -I https://domain.tld (status and headers) or curl -IL to follow the whole redirect chain..htaccess is read on every request..htaccess to .htaccess_old. If the error disappears, the cause is inside the file. For WordPress, regenerate a clean one with Settings → Permalinks → Save Changes, then add custom rules back one by one.
<IfModule>, or a directive that is not allowed in .htaccess.Deny from all / Require all denied rules or IP blocks left by security plugins..htaccess problem.HTTP to HTTPS, and non-www to www:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Usual causes of a loop:
%{HTTPS} is always off and the rule fires forever. Fix: set Cloudflare SSL to Full (strict)..htaccess, an SSL plugin and hPanel's Force HTTPS. Keep one.#) and re-test with curl -IL.Sources: non-www redirect guide, 302 error guide
LimitRequestBody line in .htaccess; remove or raise it.upload_max_filesize and post_max_size in hPanel's PHP Configuration, within the plan's limits.Source: 413 guide
max_execution_time in hPanel's PHP Configuration, the Resource Usage tab, and the access logs for slow or heavy requests (bots, wp-cron, admin-ajax.php).Source: 504 guide
.htaccess, use the isolation trick (rename the file) rather than server-level settings.Source: Error 520 guide
# Disable directory listing
Options -Indexes
# Protect wp-config.php
<Files wp-config.php>
Require all denied
</Files>
# Block XML-RPC (breaks Jetpack and the WordPress mobile app)
<Files xmlrpc.php>
Require all denied
</Files>
# Basic security headers
<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
Block PHP execution in uploads with a separate file at wp-content/uploads/.htaccess:
<FilesMatch "\.php$">
Require all denied
</FilesMatch>
ServerTokens) and choosing TLS versions are server-level settings. They do not work in .htaccess and are handled on our side.
/home/[username]/.logs/error_log. Replace [username] with the account's username.
See Error 520 guide
curl -I: status code, location for redirects, and server / cache headers..htaccess breakage follows one of these.Give each specialist one of the broken .htaccess files below. Ask them to find the cause with curl -I, the error log and the isolation trick, and to explain the fix as they would to a customer.
Case A: the redirect never happens
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect 301 /old-page/ https://example.com/new-page/
The WordPress block already rewrites the request to index.php, so the custom redirect at the bottom is reached too late or behaves inconsistently. Move it above # BEGIN WordPress.
Case B: 500 right after a migration
# php -- BEGIN cPanel-generated handler, do not edit
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# BEGIN WordPress
...
# END WordPress
A handler left by the previous host points to a PHP version that does not exist here. Remove the cPanel block and set the PHP version in hPanel.
Case C: ERR_TOO_MANY_REDIRECTS, site behind Cloudflare
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
The rule is correct, but Cloudflare SSL is set to Flexible, so the server always sees HTTP and keeps redirecting. Set Cloudflare SSL to Full (strict); curl -IL shows the same location repeating.
Adapted from the Dex outline, refocused on Apache and .htaccess. Linked points come from Hostinger tutorials; the rest (WordPress default block, rewrite flags, hardening snippets, lab cases) is general Apache and WordPress practice, not taken from our docs. The Mastery initiative page has no session plan for this topic, so this outline is a suggestion.