partying with pyblosxom part 2
In the second part of this series, we'll look at some Rewrite Rules to stop PyBlosxom from trying to treat real URLs as blog entries. If you haven't already, please read Chapter 2 and Chapter 3 of the PyBlosxom manual -- specifically this part on Rewrite Rules.
Using the example in the docs, say you create a link to your site that looks like this:
http://example.com/blog/story.html
What the rewrite rule is doing is translating it into this:
http://example.com/~joe/cgi-bin/pyblosxom.cgi/story.html
Notice how the first one looks cleaner -- this is exactly what we're using Rewrite for!
However, say you end up creating a real directory called “blog” and have some images stored there (don't roll your eyes -- it happens!). Your URL will look like this:
http://example.com/blog/image.jpg
But since Rewrite is enabled, it will get translated to this:
http://example.com/~joe/cgi-bin/pyblosxom.cgi/image.jpg
And you'll never be able to see your image. To fix this, we'll add these Rewrite Rules above the one listed in the docs:
RewriteCond /path/to/website/blog%{REQUEST_FILENAME} !-f RewriteCond /path/to/website/blog%{REQUEST_FILENAME} !-d
These rules will check to see if a file or directory with that same name does not exist before it rewrites it using the Rewrite Rules -- so our image.jpg will now show up!
Another Rewrite rule you can use is this:
RewriteCond %{REQUEST_URI} !/images.*
This will check to see if the requested URL contains the directory of /images. If it does, the URL will not be re-written and the real URL will be displayed.
