Home / Guides / WordPress handbook / Chapter 07

WordPress handbook · Chapter 07 · Infrastructure

Apache, Nginx and .htaccess Security

Web-server rules are the layer that decides what never reaches PHP at all: configuration files, backups, scripts uploaded into the media folder, abusive endpoints. They are also the layer where one typo takes the whole site offline. Every example in this chapter states its purpose, the environment it applies to, its side effects, how to verify it, and how to roll it back.

Updated · 19 min read · Level: Advanced

On this page
  1. Before you edit any server configuration
  2. Why .htaccess does not control Nginx
  3. Why WordPress rewrite rules must not be overwritten casually
  4. Apache configuration
  5. Nginx configuration
  6. LiteSpeed notes

Before you edit any server configuration

  1. Identify the server. curl -sI https://example.com/ | grep -i '^server'. The header may be hidden or show the CDN instead, so confirm with your host. Apache-style rules do nothing on Nginx.
  2. Back up the file you are changing, with a timestamp: cp .htaccess .htaccess.bak-$(date +%Y%m%d%H%M). Keep backups outside the web root, or make sure they are denied by your rules: .htaccess.bak is not protected by the default .ht* rule on every server.
  3. Test syntax before reloading (server-level config): sudo apachectl configtest or sudo nginx -t. A failed test leaves the running server untouched; a failed reload or restart can take it down.
  4. Reload, don't restart, where possible: sudo systemctl reload nginx keeps existing connections alive.
  5. Keep a second session open (SSH or file manager) so you can revert if the change locks you out.
  6. Change one rule at a time and verify it before adding the next.
Examples that require hosting administrator approval

Anything marked Requires host / admin approval changes server-level configuration (virtual hosts, nginx.conf, Apache <Directory> blocks, module settings). On shared or managed hosting you usually cannot edit these files; ask the host to apply the equivalent. On your own server, an error here can take down every site on the machine.

Why .htaccess does not control Nginx

.htaccess is an Apache feature: per-directory configuration that Apache looks for and reads on every request, if the main configuration permits it with AllowOverride. Nginx deliberately has no equivalent. It reads its configuration once at start-up or reload, from files under /etc/nginx/, and never looks inside the website's directories for instructions. So on Nginx:

  • WordPress's permalink rules in .htaccess are ignored. Pretty permalinks work only because the server block contains try_files.
  • Security and caching plugins that "write protection rules to .htaccess" achieve nothing, while their dashboards may still say the protection is active.
  • A .htaccess file sitting in the web root is just a file. Nginx should deny it like any other dotfile.
  • Equivalent protections must be written in Nginx syntax in the server configuration, usually by the host or system administrator.

Mixed stacks complicate this. With Nginx in front of Apache, .htaccess applies only to requests Nginx passes through, not to static files Nginx serves itself. LiteSpeed reads .htaccess (with some differences on OpenLiteSpeed). Always test a protection by requesting the protected URL, not by trusting the configuration file.

Why WordPress rewrite rules must not be overwritten casually

On Apache, WordPress manages the section between # BEGIN WordPress and # END WordPress in the root .htaccess. It rewrites that section whenever permalinks are saved (and some plugins trigger this). Other plugins add their own marked sections. Problems follow when this file is handled carelessly:

  • Pasting a "complete .htaccess" from a tutorial deletes rules other plugins depend on: caching rewrites, WebP delivery, security blocks, redirects. Features silently stop working.
  • Editing inside the WordPress markers: your changes are lost the next time permalinks are saved.
  • Putting custom rules after the WordPress block: the WordPress catch-all RewriteRule . /index.php [L] sends every request for a non-existent file to WordPress first, so later rules for those paths never run.
  • Deleting the WordPress block: every URL except the home page returns 404.
  • Losing the Authorization pass-through (E=HTTP_AUTHORIZATION): application passwords and some REST integrations fail with 401.

Rule: put custom rules above # BEGIN WordPress inside your own clearly named markers, and never edit between WordPress's markers. If the WordPress block is damaged, Settings → Permalinks → Save regenerates it (when the file is writable), or wp rewrite flush --hard does the same.

Apache configuration

How .htaccess works. For each request, Apache walks from the document root down to the requested file's directory and applies every .htaccess it finds, if AllowOverride permits. Directives that the server does not allow in .htaccess, or modules that are not loaded, cause a 500 Internal Server Error for every request under that directory, with "Invalid command" or "not allowed here" in the Apache error log. Wrapping directives in <IfModule> prevents errors when a module is missing, but it also makes the rule silently do nothing, so verify each one. Server-level configuration (virtual host or <Directory>) is faster and cannot be altered by a file written by an attacker, so it is preferred where you have access.

A1 · WordPress permalink rules (the default block)

Apache 2.4 · LiteSpeed · .htaccess
Purpose
Routes requests for non-existent files and directories to index.php, so WordPress can resolve pretty permalinks.
Applicable environment
WordPress in the document root, Apache with mod_rewrite and AllowOverride FileInfo (or All). For a subdirectory install, RewriteBase and the final rule include the subdirectory.
Explanation
The first rule passes the Authorization header to PHP (needed for application passwords on CGI/FPM). Requests for index.php stop immediately. For anything else, if the path is not a real file (!-f) or directory (!-d), it is rewritten internally to /index.php.
# 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
Potential side effects
None when correct. Missing, it causes 404s on all inner pages. With AllowOverride None it is ignored entirely.
Verification
Open a post and a page by permalink; request /wp-json/ and expect JSON; curl -sI https://example.com/a-post/ returns 200.
Rollback
Restore the backup copy, or resave permalinks to regenerate.

A2 · HTTPS redirect (including behind a proxy or CDN)

Apache 2.4 · .htaccess or vhost
Purpose
Permanently redirect HTTP requests to HTTPS so every visitor uses an encrypted connection.
Applicable environment
Apache with mod_rewrite, a valid certificate installed, and WordPress URLs already set to https://. Skip this if your host or CDN already redirects. Two redirect layers that disagree cause loops.
Explanation
The first condition matches requests Apache itself received over plain HTTP. The second skips requests where a proxy or CDN reports the original request was already HTTPS (X-Forwarded-Proto), which prevents the classic redirect loop when TLS terminates at the proxy.
# BEGIN Force HTTPS (custom)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END Force HTTPS (custom)
Potential side effects
Loops if the CDN talks to the origin over HTTP and does not send X-Forwarded-Proto; set the CDN to "Full (strict)" TLS to the origin instead. 301s are cached by browsers, so test with 302 first if unsure. The HTTP-01 certificate challenge still works because ACME clients follow redirects to HTTPS on most setups, but confirm renewal afterwards.
Verification
curl -sI http://example.com/some-page/ returns one 301 to the HTTPS URL; curl -sIL shows no chain or loop; certificate renewal dry-run succeeds.
Rollback
Delete the block. Browsers that cached the 301 will keep redirecting until their cache clears, which is harmless if HTTPS works.

A3 · Disable directory listing

Apache 2.4 · .htaccess or vhost
Purpose
Stop Apache from listing directory contents when there is no index file, for example in wp-content/uploads/2026/.
Applicable environment
Apache where AllowOverride includes Options (or All). Many hosts already disable indexes globally.
Explanation
Options -Indexes removes the auto-index feature for this directory and below. Directories then return 403 instead of a file list.
Options -Indexes
Potential side effects
If the server does not allow Options overrides, this line causes a 500 error site-wide. In that case, ask the host to disable indexes, or rely on their default. Intentionally browsable folders stop listing.
Verification
curl -s -o /dev/null -w "%{http_code}" https://example.com/wp-content/uploads/ returns 403 (or a WordPress 404 page), not 200 with an "Index of" list.
Rollback
Remove the line.

A4 · Protect sensitive files (wp-config, dotfiles, backups, logs)

Apache 2.4 · .htaccess or vhost
Purpose
Deny direct HTTP access to configuration, version-control, environment, backup, dump and log files that should never be public.
Applicable environment
Apache 2.4 (Require syntax) with mod_rewrite. Apache 2.2 syntax differs and is end-of-life.
Explanation
wp-config.php is normally executed rather than displayed, but if PHP handling ever breaks, Apache would serve its source. The rewrite rule returns 403 for any path segment starting with a dot except .well-known (needed for certificate validation). The FilesMatch block denies extensions that typically hold backups, database dumps, logs and INI files (including .user.ini), plus editor backup files ending in ~.
# BEGIN Sensitive file protection (custom)
<Files "wp-config.php">
    Require all denied
</Files>

<IfModule mod_rewrite.c>
RewriteEngine On
# Block .git, .env, .htaccess, .DS_Store etc. Allow /.well-known/ for ACME and security.txt
RewriteRule (^|/)\.(?!well-known/) - [F]
</IfModule>

<FilesMatch "(\.(bak|backup|old|orig|save|swp|sql|log|ini|sh|dist|config)|~)$">
    Require all denied
</FilesMatch>
<FilesMatch "\.sql\.(gz|zip)$">
    Require all denied
</FilesMatch>
# END Sensitive file protection (custom)
Potential side effects
A plugin that legitimately serves a .log or .ini file over HTTP would break (rare). Denying files does not remove them; backups and dumps still belong outside the web root.
Verification
Request /wp-config.php, /.env, /.git/config and /wp-content/debug.log: each should return 403 (or 404 if absent). /.well-known/ paths still work.
Rollback
Remove the block.

A5 · Block script execution in the uploads directory

Apache 2.4 · uploads/.htaccessVhost variant requires host / admin approval
Purpose
Ensure that even if a PHP file reaches wp-content/uploads/, it cannot be executed or requested.
Applicable environment
Apache 2.4. The .htaccess variant works on most hosts. The <Directory> variant (server config) is stronger because an attacker who can upload a new .htaccess into uploads cannot override it.
Explanation
The FilesMatch pattern denies PHP-family extensions both at the end of the name and in the middle (shell.php.jpg), which matters on legacy servers that use AddHandler. Other script types (CGI, Perl, Python, server-side includes) are denied too. The mod_php section turns the PHP engine off for the directory where PHP runs as an Apache module.
# BEGIN No script execution in uploads (custom)
<FilesMatch "\.(?:php[0-9]?|pht|phtml|phar|phps)(?:\.|$)">
    Require all denied
</FilesMatch>
<FilesMatch "\.(?:cgi|pl|py|sh|shtml|asp|aspx|jsp)$">
    Require all denied
</FilesMatch>
<IfModule mod_php.c>
    php_flag engine off
</IfModule>
<IfModule mod_php7.c>
    php_flag engine off
</IfModule>
# END No script execution in uploads (custom)
<Directory "/var/www/example.com/public/wp-content/uploads">
    AllowOverride None
    <FilesMatch "\.(?:php[0-9]?|pht|phtml|phar|phps)(?:\.|$)">
        Require all denied
    </FilesMatch>
</Directory>
Potential side effects
Plugins that run PHP scripts from inside uploads (a poor design, but it exists in some older image or cache plugins) stop working. AllowOverride None in the vhost variant also disables other .htaccess files under uploads, including deny rules plugins write for protected download folders, so recreate those in the vhost.
Verification
Use the test in Chapter 04: a test .php file in uploads must return 403 and must never output its content. Delete the test file afterwards.
Rollback
Delete uploads/.htaccess (or the vhost block, then apachectl configtest and reload).

A6 · Security headers

Apache 2.4 · mod_headers · .htaccess or vhost
Purpose
Send baseline browser security headers on every response (Chapter 02 explains each header).
Applicable environment
Apache with mod_headers. Do not also set the same headers at the CDN or in a plugin.
Explanation
Header always set adds or replaces the header on all responses, including errors and redirects. Start HSTS with a short max-age (for example 300) and raise it once every subdomain is confirmed on HTTPS.
# BEGIN Security headers (custom)
<IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
    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"
    Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
</IfModule>
# END Security headers (custom)
Potential side effects
HSTS makes any subdomain without valid HTTPS unreachable for the max-age period; SAMEORIGIN stops other sites framing yours (including some embed and preview tools); Permissions-Policy disables those features for embedded content too.
Verification
curl -sI https://example.com/: each header appears exactly once. Test the block editor, page-builder editor, payment checkout and embeds.
Rollback
Remove the lines. HSTS persists in browsers that saw it until max-age expires.

A7 · Block XML-RPC (only if unused)

Apache 2.4 · .htaccess
Purpose
Stop brute-force amplification and pingback abuse via xmlrpc.php.
Applicable environment
Sites that do not use XML-RPC clients. Check for Jetpack features, legacy mobile publishing apps or remote-publishing tools first.
Explanation
Denies the file at the web server, so the requests never reach PHP and cost almost nothing.
<Files "xmlrpc.php">
    Require all denied
</Files>
Potential side effects
Anything relying on XML-RPC breaks, including pingbacks.
Verification
curl -s -o /dev/null -w "%{http_code}" -X POST https://example.com/xmlrpc.php returns 403.
Rollback
Remove the block.

Nginx configuration

Server blocks and location matching. A server block is a virtual host, selected by listen port and server_name. Inside it, location blocks match the request URI using rules that surprise people coming from Apache:

  1. Exact matches (location = /xmlrpc.php) win immediately.
  2. Otherwise, the longest matching prefix location is remembered. If it uses ^~, it wins and regexes are not checked.
  3. Otherwise, regex locations (~ case-sensitive, ~* case-insensitive) are checked in the order they appear in the file, and the first match wins.
  4. If no regex matches, the remembered prefix location is used.

Rule 3 is the source of a dangerous mistake: if location ~ \.php$ (pass to PHP) appears before a regex meant to deny PHP in uploads, the PHP block matches first and the uploaded script runs. Security regex locations must come before the PHP location.

FastCGI and PHP-FPM. Nginx passes PHP requests to PHP-FPM through fastcgi_pass (a Unix socket such as /run/php/php8.3-fpm.sock, or 127.0.0.1:9000). The SCRIPT_FILENAME parameter tells PHP-FPM which file to execute. try_files $uri =404 inside the PHP location ensures only PHP files that actually exist are passed on, which prevents path-confusion attacks.

N1 · WordPress server block with HTTPS and PHP-FPM

Nginx · server configRequires host / admin approval
Purpose
A complete, minimal HTTPS server block for a single WordPress site, including permalinks and PHP-FPM integration.
Applicable environment
Self-managed Nginx (Debian/Ubuntu paths shown) with PHP-FPM and a certificate from an ACME client. Adjust paths, PHP socket and server names. http2 on; needs Nginx 1.25.1+; older versions use listen 443 ssl http2;.
Explanation
try_files $uri $uri/ /index.php?$args is the Nginx equivalent of WordPress's .htaccess: serve the file or directory if it exists, otherwise hand the request to WordPress. The security include is placed before the PHP location (see N3 and N4). client_max_body_size sets the upload limit at this layer.
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name example.com www.example.com;

    root /var/www/example.com/public;
    index index.php;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    client_max_body_size 64m;          # keep in step with PHP upload/post limits

    include snippets/wp-headers.conf;  # N6: security headers
    include snippets/wp-security.conf; # N3 + N4: MUST come before the PHP location
    include snippets/wp-static.conf;   # N5: static file caching

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;           # only pass PHP files that exist
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_read_timeout 120s;     # match PHP max_execution_time policy
    }
}
Potential side effects
A wrong socket path gives 502 for every PHP request. Missing try_files on / makes every permalink 404. Plugins that rely on .htaccess rules (WebP rewrites, protected download folders, cache rewrites) need Nginx equivalents from their documentation.
Verification
sudo nginx -t, then reload. Test home, a permalink, /wp-admin/, /wp-json/, an upload, and a 404 URL (should show the theme's 404 page).
Rollback
Restore the previous file from backup, nginx -t, reload.

N2 · HTTP to HTTPS redirect server block

Nginx · server configRequires host / admin approval
Purpose
Redirect all port-80 traffic to HTTPS while still allowing HTTP-01 certificate challenges.
Applicable environment
Nginx terminating TLS itself. If a CDN terminates TLS and connects to the origin over HTTPS, the CDN usually handles the redirect instead.
Explanation
The ^~ prefix location for /.well-known/acme-challenge/ serves challenge files without redirecting. Everything else is redirected with 301, preserving host and path.
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;

    location ^~ /.well-known/acme-challenge/ {
        root /var/www/example.com/public;   # where your ACME client writes challenges
        default_type text/plain;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}
Potential side effects
If WordPress's home URL is still http://, WordPress redirects back and loops. Update the URLs first.
Verification
curl -sI http://example.com/page/ returns 301 to HTTPS; a certificate renewal dry run succeeds.
Rollback
Restore the previous port-80 block and reload.

N3 · Sensitive file restrictions

Nginx · snippet included in server blockRequires host / admin approval
Purpose
Deny dotfiles, wp-config.php, backups, dumps, logs and (optionally) XML-RPC before they reach PHP or are served as static files.
Applicable environment
Nginx; include before the PHP location.
Explanation
The first block denies any path segment starting with a dot except .well-known. The exact match for xmlrpc.php takes precedence over all regexes. wp-config.php and backup-style extensions are denied by regex, which works only because these blocks appear before the PHP regex location.
# Dotfiles (.git, .env, .htaccess, .user.ini), but keep /.well-known/ working
location ~ /\.(?!well-known/) {
    deny all;
}

# Configuration file
location ~* (^|/)wp-config\.php$ {
    deny all;
}

# Backups, dumps, logs, ini/shell files, editor leftovers
location ~* \.(?:bak|backup|old|orig|save|swp|sql|log|ini|sh|dist)$ {
    deny all;
}
location ~* \.sql\.(?:gz|zip)$ {
    deny all;
}
location ~ ~$ {
    deny all;
}

# XML-RPC: only if nothing on the site uses it
location = /xmlrpc.php {
    deny all;
    access_log off;
    log_not_found off;
}
Potential side effects
XML-RPC clients break. An over-broad regex can block legitimate files, so test any extension you add. Avoid copying rules that deny all PHP under wp-includes: core still serves some PHP from there (for example the classic editor's TinyMCE loader).
Verification
Request /.env, /.git/config, /wp-config.php, /wp-content/debug.log, /xmlrpc.php: all 403. /.well-known/security.txt (if present) still 200.
Rollback
Remove the include line (or the specific block), nginx -t, reload.

N4 · Upload directory restrictions

Nginx · snippet included in server blockRequires host / admin approval
Purpose
Ensure PHP files in uploads are never passed to PHP-FPM, and protect private upload folders.
Applicable environment
Nginx; must appear before location ~ \.php$. Add any plugin-specific private folders (for example WooCommerce downloadable product storage) as deny prefix locations.
Explanation
The regex matches PHP-family extensions under /wp-content/uploads/ and denies them. Because it is listed first, it wins over the PHP handler. The ^~ prefix location for woocommerce_uploads denies the whole folder; files there should be delivered through WooCommerce's download handler (ideally using X-Accel-Redirect, which reads files from internal locations that clients cannot request directly).
# Never execute scripts from uploads
location ~* ^/wp-content/uploads/.*\.(?:php[0-9]?|pht|phtml|phar|phps)$ {
    deny all;
}

# Private download folders: deny direct access
location ^~ /wp-content/uploads/woocommerce_uploads/ {
    deny all;
}

# Optional: internal location for X-Accel-Redirect from a PHP download handler
# location /protected-files/ {
#     internal;
#     alias /home/example/private-uploads/;
# }
Potential side effects
Same as A5: plugins executing PHP from uploads break. Denying woocommerce_uploads requires WooCommerce's file download method to be "Force downloads" or "X-Accel-Redirect/X-Sendfile", not "Redirect only".
Verification
Use the Chapter 04 test file; expect 403. Download a purchased test product through the customer account and confirm it works, while the direct file URL returns 403.
Rollback
Remove the blocks, nginx -t, reload.

N5 · Static file handling

Nginx · snippet included in server blockRequires host / admin approval
Purpose
Serve static assets efficiently with long browser-cache lifetimes, without logging every hit.
Applicable environment
Nginx serving files directly; skip if a CDN controls asset caching.
Explanation
expires sets both Expires and Cache-Control: max-age. It deliberately uses no add_header: an add_header inside this location would stop the server-level security headers (N6) being inherited for these files. Missing files fall back to WordPress so virtual or generated assets still resolve.
location ~* \.(?:css|js|mjs|map|jpg|jpeg|png|gif|webp|avif|svg|ico|woff2?|ttf|otf|mp4|webm)$ {
    expires 30d;
    access_log off;
    try_files $uri /index.php?$args;
}
Potential side effects
Assets updated without a new URL stay cached in browsers for up to 30 days. Make sure themes and optimisers version their asset URLs.
Verification
curl -sI https://example.com/wp-includes/css/dist/block-library/style.min.css shows Cache-Control: max-age=2592000 and the security headers.
Rollback
Remove the include and reload.

N6 · Security headers and the add_header inheritance trap

Nginx · snippet included in server blockRequires host / admin approval
Purpose
Send baseline security headers on all responses.
Applicable environment
Nginx; not also set by the CDN or a plugin.
Explanation
always makes the header appear on error responses too. Inheritance trap: add_header directives are inherited from the server level only if the location block defines no add_header of its own. A single add_header Cache-Control ... in a location silently drops every security header for the URLs it matches. Either repeat the include in such locations or avoid add_header in locations.
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
Potential side effects
As for A6.
Verification
Check headers on an HTML page and on a static asset and an error page; all should carry them once.
Rollback
Remove the include, nginx -t, reload.

N7 · Request size and timeout limits

Nginx · http, server or location contextRequires host / admin approval
Purpose
Align Nginx limits with PHP so uploads and long admin operations fail predictably, not with confusing 413/504 errors.
Applicable environment
Nginx in front of PHP-FPM.
Explanation
client_max_body_size (default 1 MB) caps request bodies; exceeding it returns 413 before PHP runs. fastcgi_read_timeout (default 60 s) is how long Nginx waits for PHP to respond; exceeding it returns 504 while PHP may still be working. client_body_timeout limits gaps between body packets from slow clients.
client_max_body_size 64m;     # ≥ PHP post_max_size
client_body_timeout 60s;
fastcgi_read_timeout 120s;    # ≥ typical slow admin request; not a fix for slow code
Potential side effects
Large limits make it easier to tie up resources with huge or slow requests. Raise them only as far as real use requires.
Verification
Upload a file just below the limit (success) and just above (413 from Nginx, or better, your application's own error).
Rollback
Restore the previous values and reload.

LiteSpeed notes

LiteSpeed Web Server (commercial) reads .htaccess in the same way as Apache, so the Apache examples A1–A7 generally apply. Differences to know:

  • LiteSpeed reads php_value/php_flag from .htaccess when PHP runs through LSAPI, so .htaccess PHP settings that would break Apache+FPM may work here, and the reverse when migrating.
  • OpenLiteSpeed supports rewrite rules from .htaccess but may need a server restart (or a configured auto-reload) for changes to take effect; other directives may be ignored. Configure security rules in the WebAdmin console's context settings.
  • The LiteSpeed Cache plugin writes its own .htaccess blocks (# BEGIN LSCACHE) for server-level caching. Do not remove them by hand, and do not run a second page-caching plugin alongside it.

Rather have someone else keep WordPress healthy?

Our managed hosting and care plans cover updates, backups, security monitoring and fixes like the ones in this handbook, so you can get on with running the business.

See Hosting & Care