Apache configuration for silent rewrite of query strings like codeigniter

Posted by jwir3 on Server Fault See other posts from Server Fault or by jwir3
Published on 2012-04-01T01:44:54Z Indexed on 2012/04/01 5:31 UTC
Read the original article Hit count: 486

Filed under:
|

Codeigniter rewrites query strings like the following:

http://somedomain.com/index.php?q=something

to become:

http://somedomain.com/index.php/q/something

I'd like to imitate this behavior on a (very) lightweight website I am developing for a wedding RSVP system. I don't want the bloat of codeigniter, nor do I need anything else that it provides. The only thing I'd like is this.

Unfortunately, I don't know how to setup a mod-rewrite rule that accomplishes this. I can setup a rule that translates /q/something into ?q=something, but I can't get one that does that without changing the URL the user is viewing.

I'm basically looking for something that is, in effect, a "silent" version of the rewrite. That is, I want something that rewrites q/something to ?q=something, but leaves the user's URL in their address bar as q/something.

Thanks in advance!

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about querystring