You're back! Be sure to follow me on Twitter before leaving.
To me, .htaccess is a necessary demon that I have to live with. Whilst I have a basic understanding of how the file works, the fickleness in which it can break is enough to drive me insane. Yesterday (and part of today) I had that feeling. And here’s a post explaining how it was solved, with a huge credit to Mike Osolinski. I only met Mike through Twitter after an RT from Pete – just goes to show the genuin quality of a strong social media network
The situation as I described was the following:
- Client website is static HTML
- WordPress is installed within a directory (/news)
- Webmaster Tools reporting thirty-six 404 errors from the old website that need redirecting
- Adding redirects manually to the .htaccess file is causing 500 errors
So let’s go through each stage as we approached the fix:
WordPress and .htaccess
By default, WordPress uses htaccess to control it’s permalink structure using the code below. You’ll notice that if you set a custom permalink structure, it will ask you to update your .htaccess file, or make it writable.
# 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
redirect 301 /contact.aspx http://www.clientsite.com/contact.html
Line 14 Indent at beginning of line also 2 301′s on the same line.There are a number of lines where there is only one url and nothing specified to redirect to, There also seemed to be a line space at the end.
- We had the right idea, because Mike’s first htaccess file worked. So it was something within the redirects themselves that was causing the problem.
- We were on the correct FTP setting – ASCII worked, Auto didn’t (which meant Binary didn’t either)
[Fri Jan 14 14:08:43 2011] [alert] [client 188.220.6.98] /var/www/vhosts/ADDRESSREMOVED/httpdocs/.htaccess: Redirect to non-URL
Pete was right, the error logs gave some key information that led to the fix. The above statement, ‘redirect to non-URL’ was suggesting that there was an error in the way the URLs were written in the .htaccess file. Pete also mentioned that the destination URL should be absolute meaning the full address should be included. E.g.:
redirect 301 /page.php /page2.html (WRONG)
redirect 301 /page.php http://www.site.com/page2.html (CORRECT)
After completing the following checks, the file now works!
- No extra spaces or unnecessary line breaks
- ASCII transfer setting on FTP client
- ANSI encoding of the .htaccess file
- Destination URL must be absolute (the full http://www….) (See here)
These settings may not work for you – there’s a lot of factors to consider. But this post will hopefully give you some ideas to help identify the problem you might have.
- Copy the URLs from your original spreadsheet download. Because it opens in a spreadsheet, this is easy enough to do.
- Next step is to load up URL Opener and paste your list into the box.
- Run the URLs and give them a moment to load.
- Select through theĀ browser tabs and close them one after another. If you spot an error, move on to the next until you only have erroneous tabs open. Hopefully you’ll find you won’t have any!


I have a passion for Search Engine Marketing and Social Media, and I'm the proud Director of my exciting new venture,
{ 1 trackback }
Comments on this entry are closed.