htaccess Rules for WordPress Permalinks

by Ed Gately on February 24, 2010 · 0 comments

in Setting Up Wordpress,Wordpress Blogging

I recently moved a website for a client from one hosting company to another hosting company.  The entire blog was broken though.  Every time I clicked a link or tried to visit a post it resulted in a “Page not Found”.  From looking at the URL, it was obvious that it was using Permalinks.

Since the site was failing to display these pages using permalinks, the problem was with the .htaccess file.  Sure enough I opened it up and the .htaccess file was empty.  So while the most common problem is the the htaccess file is forgotten and not moved, in this case on the previous host it just didn’t exist.

Unfortunately, I didn’t have access to the clients WordPress Admin so I couldn’t regenerate the htaccess file.  Instead I had to go look for it on another WordPress installation.

For those of you that might not have access to easily look this up (and for my own reference later), here is what the .htaccess file should look like (2 versions):

Version 1: (root installation)
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Version 2: (subdirectory such as in this case “blog”)
# BEGIN WordPress
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
# END WordPress

So just make sure you have that file out there and actually have the proper information in the file so that it works.

Related posts:

  1. Redirecting Feed to Feedburner with htaccess
  2. Moving your WordPress Site? Don’t forget hidden files.
  3. WordPress 2.7 Permalink Issue and Fix
  4. Upload Permissions for WordPress in Plesk
About The Author: Hi, I'm Ed Gately and I write Wordpress Master to help bloggers get started in building a successful online blog using Wordpress. Prior to writing on this blog I spent over 16 years working in Corporate IT and have been spreading my wings on the web for 3 years. To learn more about this website and me visit About Wordpress Master.

Leave a Comment

Previous post:

Next post: