Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/18/d158249911/htdocs/blogs/inc/_core/_misc.funcs.php on line 5524

Deprecated: Function get_magic_quotes_gpc() is deprecated in /homepages/18/d158249911/htdocs/blogs/inc/_core/_param.funcs.php on line 2220

Warning: Cannot modify header information - headers already sent by (output started at /homepages/18/d158249911/htdocs/blogs/inc/_core/_misc.funcs.php:5524) in /homepages/18/d158249911/htdocs/blogs/inc/_core/_template.funcs.php on line 398

Warning: Cannot modify header information - headers already sent by (output started at /homepages/18/d158249911/htdocs/blogs/inc/_core/_misc.funcs.php:5524) in /homepages/18/d158249911/htdocs/blogs/inc/_core/_template.funcs.php on line 40

Warning: Cannot modify header information - headers already sent by (output started at /homepages/18/d158249911/htdocs/blogs/inc/_core/_misc.funcs.php:5524) in /homepages/18/d158249911/htdocs/blogs/inc/_core/_template.funcs.php on line 336

Warning: Cannot modify header information - headers already sent by (output started at /homepages/18/d158249911/htdocs/blogs/inc/_core/_misc.funcs.php:5524) in /homepages/18/d158249911/htdocs/blogs/inc/_core/_template.funcs.php on line 337

Warning: Cannot modify header information - headers already sent by (output started at /homepages/18/d158249911/htdocs/blogs/inc/_core/_misc.funcs.php:5524) in /homepages/18/d158249911/htdocs/blogs/inc/_core/_template.funcs.php on line 338

Warning: Cannot modify header information - headers already sent by (output started at /homepages/18/d158249911/htdocs/blogs/inc/_core/_misc.funcs.php:5524) in /homepages/18/d158249911/htdocs/blogs/inc/_core/_template.funcs.php on line 339
Category: "PHP" - Charlie's Thoughts

Category: "PHP"

Mod_Rewrite Problems and Solutions

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

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/18/d158249911/htdocs/blogs/plugins/_bbcode.plugin.php on line 234

Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/18/d158249911/htdocs/blogs/plugins/_auto_p.plugin.php on line 502

Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/18/d158249911/htdocs/blogs/plugins/_auto_p.plugin.php on line 500

Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/18/d158249911/htdocs/blogs/plugins/_auto_p.plugin.php on line 500

Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/18/d158249911/htdocs/blogs/plugins/_texturize.plugin.php on line 116

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:
http://www.yaledramacoaltion.org/view_show.php?show_id=31
it can now be accessed at:
http://www.yaledramacoaltion.org/romance
and
http://www.yaledramacoaltion.org/reserve/romance

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.

Search

  XML Feeds

Advanced CMS