Codeigniter rewrites query strings like the following:
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, 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, but leaves the user's URL in their address bar as
Thanks in advance!
In the .htaccess file for the site, I have the following:
RewriteEngine on RewriteRule ^/index.php/q/(.*) /index.php?q=$1
In the basic configuration for the site (/etc/apache2/sites-available/mysite.conf), I have:
<VirtualHost *> ServerAdmin email@example.com ServerName www.mysite.com DocumentRoot /var/www/www.mysite.com Options -Indexes +FollowSymLinks </VirtualHost>
The index.php file is currently simply printing out the value of
$_GET['q']. Now, when I visit the site
http://www.mysite.com/index.php?q=12345, it displays "12345" as expected. But, when I navigate to
http://www.mysite.com/index.php/q/12345, it doesn't display anything. Or, rather, it appears that the value for the query string is empty. I'm not quite sure what I'm doing incorrectly.