HTTP Error 301: Permanent Redirect

A while ago, I explained how I configured the server to return HTTP Error 410: Gone for all requests for pages created with my old CMS.

After installing Movable Type, all pages of my site moved to another location, and I was not able to work out the new location of the files. In short, error 410 says: The requested file used to exist on this location, but it has gone to an unknown location. This message is more clear than the message returned by default; the famous 404.

I always check the server logs for 404 messages, since it might indicate that a link on the site is wrong and I’ll have to fix that. One of the files coming up regulary in that log is the default MT stylesheet styles-site.css, which I have replaced by my own stylesheet with a different name.

I immediately wanted to add this file to my ‘410–list’, but then I realised that 410 is not the correct code, since I do know where the file went.

Therefore a better solution would be to return code 301 (permanent redirect) together with the new location, so any smart client would simply redirect to the new address.

To implement this, I only needed to add a single line to the .htaccess file:

Redirect permanent /styles-site.css

This line tells the server to redirect requests for /styles-site.css with code ‘permanent’ to the file Remember that the destination always has to be a complete URL!!

Jeroen Sangers @jeroensangers