How to: Replace WordPress .htaccess

Replace a corrupt or lost WordPress .htaccess

wordpress_logoWordPress uses .htaccess for security and for URL re-writing and so it is a key contributor to the functionality of your site. Sometimes you will find your site looking very badly formatted, as if the CSS files are not being found.

The problem is usually caused by a corrupt or lost .htaccess file. This can be caused by a misbehaving/bad plugin feature or update.

Never fear, you can replace the default WordPress .htaccess file and get your site looking great again.

There are two default formats for WordPress .htaccess depending on the version you are running. Basically, if the first doesn’t work, simply try the second.

The “Basic WordPress” .htaccess

If your WordPress was installed in document root:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

The “MultiSite WordPress” .htaccess

If your WordPress was installed in a sub-folder:

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]
Was this helpful?
How to: Replace WordPress .htaccess written by UKC average rating 2.7/5 - 3 user ratings