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: