.htaccess snippets

Simple cut-and-paste snippets for your .htaccess files when working with static and WordPress websites.

Add these to increase security, performance and increased functionality to your WordPress websites.

Deny access to wp-config.php

<files wp-config.php>
order allow,deny
deny from all

301 Redirect

Redirect 301 /oldpage.htm https://www.your-website.com/newpage.htm

Force www domain

#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^your-website.com [NC]
RewriteRule ^(.*)$ https://www.your-website.com/$1 [L,R=301,NC]

Leave a Comment