.htaccess URL rewrite to multi-parameter item

Posted by MrCS on Server Fault See other posts from Server Fault or by MrCS
Published on 2011-11-23T07:13:23Z Indexed on 2011/11/23 9:54 UTC
Read the original article Hit count: 189

Filed under:
|

I just spent the last 10 hours of my life on this & am running in circles, so was hoping someone may be able to help me.

I want a specific URL to load like this:

http://example.com/f/2011/image.png?attribute=small

When a URL in a format such as this hits, I'd like to rewrite it to hit the server as:

http://example.com/generate.php?f=2011/image.png&attribute=small

Based on above, my question is two-fold:

  1. How can I rewrite the URL in htaccess to meet my requirements above?
  2. If the original URL didn't have the attribute query string parameter, how can I ensure attribute will be false/blank/etc when it hits the server via htaccess?

© Server Fault or respective owner

Related posts about .htaccess

Related posts about url-rewriting