Site htaccess changes

I’ve finally gotten around to messing with my htaccess file and added the following:

# Error pages
ErrorDocument 404 /404.php
# Redirect
Redirect /blog/blog.html http://www.chrisnelson.ca/
Redirect /blog/index.html http://www.chrisnelson.ca/
Redirect /blog/atom.xml http://www.chrisnelson.ca/feed/atom/

The Error Pages part redirects 404 errors to my 404 page, so my hosts’ doesn’t show up. I don’t really care about the other ones, since they are infrequent. The Redirect part forwards request for my old blog & atom rss to the new wordpress spots. I’ve left my old photo pages with meta refresh directs because its already done, but more importantly, I’m lazy.

I’m also toying with the idea of killing image hotlinking, and forwarding direct images to page code with the image imbeded. This should cut down my bandwidth (site pulls around 100mb per day just in people hotlinking my images), and get people to view the site framework so their browser is sent my creative commons licence information (Put simply, you are able to copy or distribute my work as long as I get credit, there is no profit involved, and my work is not changed). I could redirect hotlinks to a picture to make sure they never hotlink again, but I’m just not that cruel.

Updated:
I implemented the htaccess rules from the alistapart link above and managed to get it working. I had to comment out the Cache-Control parts of the showpic.php file, as it was throwing 500’s all over. I also had to change the redirect and put the htaccess file and showpic file in the /gallery/albums directory. I tried the files working in / and /gallery/, but it was going to be way too much of a pain in the ass to try to compete with the rewrite rules of wordpress and gallery. Every time the showpic.php tried to display the full img url it was passed, the mod rewrite rules for gallery and wordpress would mangle it and break the image link. It is still breaking off the front of the url, but because it is in the albums directory, the relative path works out. I also modified some of the htaccess based on the code comments found here.

My testing seems to all work out so far. Any of my photos in gallery that gives a header (blank header is ok) not from Google or my site gets sent html instead of the picture. If someone clicks on a direct link to my images, they get a frame around the image. Click here to see what it looks like.

After reading through all the comments on the article, it seems there may be a better way to go (click here). But that will have to wait until I have more time to redo it all.

2 replies on “Site htaccess changes”

Comments are closed.