Try adding a /
in front of it, and a $
at the end.
Like:
RewriteRule ^/(.*)$ cgi-bin/router.py?request=$1 [NC]
Also, I find it best to use the RewriteBase
directive when testing. Then you can just alter that instead of having to mess with the regular-expressions themselves.
RewriteBase /test/
RewriteRule ^(.*)$ cgi-bin/router.py?request=$1 [NC]
And, when moved to the real-world:
RewriteBase /
RewriteRule ^(.*)$ cgi-bin/router.py?request=$1 [NC]
Edit
After some more testing, I found that the problem is perhaps not with the expression itself, but rather with your directory name: cgi-bin/
. Apache, by default, uses this directory for CGI scripts, but uses ScriptAlias
to redirect requests for /cgi-bin/*
to another directory. In my case a directory named the same in the Apache installation directory.
Is this a directory you created yourself, or are you using the directory Apache has aliased this to?
You have to either
- Use the directory Apache specifies in the configuration
- Edit the configuration to allow you to specified this yourself, or
- Choose another directory name.
Personally, I would go with #3. I tried this, and it worked fine for me.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !bin/
RewriteRule ^(.+) bin/request.php?ctrl=$1 [NC,L]
</IfModule>