WordPress .htaccess for Permalinks

Posted in Articles

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

After installing WordPress 3.8.1 at the root of the domain and then going to “Settings -> Permalinks -> Post name”, it creates a .htaccess file in the WordPress root that looks like …

# 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

But if you installed WordPress within a subdirectory (such as /blog1), then the .htaccess that it creates is …

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog1/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog1/index.php [L]
</IfModule>
# END WordPress

Typically, you should not need to code this into .htaccess file.  WordPress should be able to write this file for you.  But sometimes it is not able to and gives message “You should update your .htaccess now.”
In that case, you might have to write the .htaccess file manually.   But note that the above shown is only for WordPress 3.8.1.