Skip to content
Merlin Tools

WordPress .htaccess generator

Permalinks, HTTPS and security rules for Apache.

Genuinely free. No sign-up, no email, no limits, no cookies. We don't store the URL you analyse.

Code
# Force HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# Protect sensitive files
<Files wp-config.php>
Require all denied
</Files>
<Files .htaccess>
Require all denied
</Files>

# Block XML-RPC
<Files xmlrpc.php>
Require all denied
</Files>

# 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

What it's for

The .htaccess file tells Apache how to handle URLs and what to block. WordPress generates part of it itself (permalinks); here you safely add the most useful rules without risking syntax errors that take the site down.

← All WordPress tools

Frequently asked questions

Does this work for Nginx?

No: .htaccess is Apache-only. On Nginx the same rules go in the server configuration (location blocks), with a different syntax.