Web Hosting Talk







View Full Version : mod_rewrite woes


NE-Andy
11-18-2007, 03:48 AM
I am having some strange htaccess issue... I want all none existing file/folder requests of /login or /login/blah to be be rewritten to admin.fcgi and everything else (IE: /timeline, /wiki, /timeline/blah, /wiki/blah, etc.) to be forwarded to index.fcgi. This is my htaccess right now:
DirectoryIndex index.fcgi
<Files "admin.fcgi">
AuthType Basic
AuthUserFile /home/path/to/.htpasswd
AuthName "Trac Sign In"
require valid-user
</Files>

Options ExecCGI FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^login$ admin.fcgi/login [L]
RewriteRule ^login/(.*)$ admin.fcgi/login/$1 [L]
RewriteRule ^logout$ index.fcgi/logout [L]
RewriteRule ^logout/(.*)$ index.fcgi/logout/$1 [L]
RewriteRule ^(.*)$ index.fcgi/$1 [L]
</IfModule>

But I get HTTP 500 errors with that... any recommendtations on how to fix it and why? >_<

foobic
11-18-2007, 05:42 PM
You can't stack multiple rewriteRules after a series of rewriteConds (well, you can, but after the first rule the others are applied whether the condition is true or not). So your rules will redirect index.fcgi to itself endlessly. Try this (untested):
RewriteEngine On
RewriteBase /
RewriteRule ^(login|logout)/?(.*) admin.fcgi/$1/$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.fcgi/$1 [L]