Tag Archives: mod_rewrite

Mod_rewrite doesn’t look at arguments? D’oh!

Mod_rewrite doesn’t look at arguments? D’oh!

Posted on 09. Jun, 2009 by Carolyn Shelby.

4

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

When I converted my old, kloodgy Web site into WordPress last year, one of the reasons I did so was because my restaurant review script was no longer supported and had some ginormous security holes. It was open to all kinds of cross-site script injection and it was becoming a one to two hour a day chore to keep it running.

The new solution (WordPress) is fabulous, but now I have a couple hundred inbound links that are broken. Trying to get all of the links updated by the other sites was a losing proposition, so my next step was to put some 301 redirects into my friendly neighborhood .htaccess file and transfer all the link love to the new pages.

Easy (normal) 301 redirects via .htaccess
Normally, a 301 redirect in your .htaccess file would look like this:
Redirect 301 /old/url.shtml http://domain.com/new/filename
or if we’re being fancy…
RewriteEngine on
RewriteBase /
RewriteRule ^old/url.shtml$ new/filename [R=301,L]

Normally, the examples above are perfect for redirecting incoming links from old, defunct pages to the new, correct location of the file. The problem I ran into is that my pages were dynamically generated; i.e., they all shared the same URL, and which review was presented to the user was determined by an argument passed in the URL after the file extension.
http://www.domain.com/cgi-bin/script.cgi?review=bobs_shrimp_hut

To address this, I figured I would just [...]

Popularity: 33% [?]

Continue Reading