Category: "PHP"

Mod_Rewrite Problems and Solutions

03/30/09 | by Comp615 [mail] | Categories: PHP

So over the break I updated the Yale Drama Coalition website to have a reservation system! However, so that the addresses look pretty on posters, I wanted to use mod-rewrite, an apache webhost mod, to change the urls.

Basically instead of our Romance show url being:
it can now be accessed at:

Notice how those are much prettier (and easier to remember). Unfortunately, to do this requires some work at the top level of a website. It seems I accidentally got the file into my blog directory, so sorry to anyone who tried to get to the site in the past day.

Anyways, if anyone else is looking for help getting mod_rewrite to work, I found two very helpful resources:
this cheat sheet for mod rewrite was great and condensed all the information onto a single page!

Second, I was using the [R] tag for awhile, which literally redirects to the underlying page instead of masking it. The reason for this was that /reserve/ makes the page think it's in the reserve directory, so all the links break. To fix this I found a post on mod_rewrite forums which gave some solutions. Unfortunately, I've always used relative links, meaning I used the 5th option of a base tag to fix it.

Now everything's fine and dandy. This technique is great for search engine friendliness, is somewhat logical, and works better on print and when giving out the link!

Real information on my life to come later.

A collection of musings from my time at Yale along with some thoughts about my "Freshman year of life" in San Francisco.


  XML Feeds

powered by b2evolution free blog software