I'm trying to write an htaccess file and I'm having trouble getting it to work properly. There's a directory on my site called 'gpio'. The htaccess file that I'm writing is in /var/www/gpio.
When someone requests the URL http://domain.com/gpio, I want the request to be redirected to a script, with 'gpio' appended to the query string. This is what I've got in my htaccess file:
# .htaccess
#DirectoryIndex index.html
RewriteEngine on
# I changed domain name a few months ago...
RewriteCond %{HTTP_HOST} ^olddomain.com/*$
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
# handle the case where the directory exists
RewriteCond %{REQUEST_FILENAME} -d
# this is the part that doesn't work
RewriteRule ^(.*)$ /cgi-bin/pyindex.cgi?q=$1 [L,QSA]
# handle the case where a file is requested
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /cgi-bin/pyindex.cgi?q=$1 [L,QSA]
The problem is that when I visit this URL, I get redirected to the script, but the requested path doesn't get appended to the query string. In pyindex.cgi, when the query string is printed, it just contains 'q='. The end result is that I'm seeing my home page when I should be seeing a page representing a category of posts.
Any thoughts on what I'm doing wrong would be appreciated.