mod_rewrite woes

Discussion in 'Apache' started by Alfarin, Nov 17, 2007.

  1. #1
    I'm trying to rewrite trac; but seems to be failing quite miserably...

    I'm on shared hosting, so I need to do some custom hacks to get the logins to work, and here's what I've got so far:
    I've setup index.fcgi in such a way so that it maps itself to trac.fcgi in trac's directory and works withmy project:
    
    #!/bin/bash
    export HOME="/home/user_account"
    export TRAC_ENV="$HOME/trac_sites/project_name"
    export PYTHONPATH="$HOME/lib/python2.5/site-packages"
    export PATH="$HOME/bin:$PATH"
    export LD_LIBRARY_PATH="$HOME/lib"
    
    exec $HOME/share/trac/cgi-bin/trac.fcgi
    Code (markup):
    I've checked via web url, and it works.

    I've copied it into admin.fcgi, and setting admin.fcgi require login via htaccess, I've then added these to make URL look pretty, but it doesn't seem to work... at all :/
    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>
    
    Code (markup):
    Any idea what's causing it to err? :/

    What I need is:
    If requested file is not a file nor a directory:
    - If url is login or login/blah, go to admin.fcgi/login, and require htpasswd login
    - If url is logout or logout/blah, go to index.fcgi/logout
    - If url is anything else, go to index.fcgi/<whatever>

    The above gives HTTP 500 :/
     
    Alfarin, Nov 17, 2007 IP