What’s the default .htaccess file for WordPress?

This knowledgebase article is design to restore a corrupted .htaccess file for WordPress (v3.5 or newer), and does not account for any changes that may have been made by your web designer or theme author.  The .htaccess is a distributed configuration file, and is how Apache handles configuration changes on a per-directory basis.

Its whole existence within WordPress is to manipulate how Apache (a piece of software on your web server) serves files from its root directory, and subdirectories thereof.  Most notably, WP modifies this file to be able to handle pretty permalinks.

 

If you’re using a basic single-site WordPress installation

# 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

 

If you’re using a multi-site WordPress installation

If you activated Multi-site on WordPress 3.5 or later, use one of these.

Option 1: Sub-folder installation

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

 

 

Option 2: Sub-domain installation

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

 

Where can I find more help?

You can find more help and details of the components of the .htaccess file on WordPress’ Codex site at https://codex.wordpress.org/htaccess.  Alternatively, please contact us for help and assistance…

Share

Leave a comment