I was cleaning up my other hosted website, mntbd.com, and I removed an entire directory dedicated to Murray, my old middle school. I was hosting the flash creations that the kids made so they could show their parents and friends. I figure that someone might come looking for those old files so I needed a nice way to present an discontinue notice for anyone who enters the murray directory on my web server.
My first thought was to use an htaccess in the murray directory and when someone got a 404 error, it would show them the discontinue notice. But I wanted to completely remove the directory. The htaccess code for that isn’t hard either.
ErrorDocument 404 /murray/index.html
However, the solution was so much more elegant than that! I thought then, let’s scrap the directory and let’s move the error notice outside of the murray directory and put it in the root level directory. Then, using a redirect statement in htaccess, I could capture any request to the murray directory and redirect it to the notice.
Here’s my htaccess code for that:
RedirectMatch 301 /murray/ http://mntbd.com/murray-notice.html
What does it do exactly? It’ll capture any request for /murray/ and send a 301 (which is permanent, so google doesn’t hate us) to the static notice html file in the root directory. Isn’t that easy?
It’s clean and cheap. It gets rid of a directory and it allows for universal coverage, nobody is going to miss that notice if they’re looking for the old Murray Creations website.