Forum Moderators: phranque

Message Too Old, No Replies

rewriterule fail in cgi-bin directories

Unable to rewrite anything in cgi-bin eg, /cgi-bin/webmail?index=1

         

daxal

11:45 am on Jan 1, 2004 (gmt 0)

10+ Year Member



I have many websites (atleast 60?) managed with mod_macro. This is my primary reason for using .htaccess files to add rewrite rules here and there. I may add "yet another" macro into the configuration, just for webmail sites. I'd perfer a .htaccess alternative.

The webmail pages need a .htaccess file to redirect specific urls to the main site (usualy after webmail logs out). The goal is to redirect to the home page when they log out of webmail. Many new users will get lost without this.

rewriterule catches attempts for [webmail.example.com...] and redirects to [example.com...] that's ok. (the webmail login is on www anyway...)

However, this walk-through demonstrates where it does not work.

Start -> [example.com...]

Type in your user+password for webmail, and hit login.

Action ->

[webmail.example.com...]

Read email, send email, delete email, do stuff.

Logout of webmail ->

[webmail.example.com...]

I've tried multiple rewriterules to try and match this. (all in .htaccess, either in the docroot, or in cgi-bin)

The rewrite log, at level 2 shows NOTHING when accessing /cgi-bin*, however, it runs as expected for other locations (eg, a virtualized directory structure mapped to a php script one of the non webmail hosts)

It's not feasable (imo) to put these rewrites in the httpd.conf. I'm willing to open up access specific to this function, to allow it to operate.

I'm still at odds with it. It's to my (possibly misguided) understanding that allowoverrides and options directives will not affect mod_rewrite or its directives.

Thank you!

Scott

PS, have a happy GNU year ;-)

jdMorgan

9:01 pm on Jan 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



daxal,

Welcome to WebmasterWorld [webmasterworld.com]!

> allowoverrides and options directives will not affect mod_rewrite or its directives.

AllowOverides Fileinfo is required on some servers.

If Options FollowSymLinks is not set in httpd.conf, then AllowOverrides Options must be set so that Options +FollowSymLinks can be set in the .htaccess context.

In addition, you may find that setting AllowOverrides Limit is to your advantage.

If you'll post your code for redirecting http://webmail.example.com/cgi-bin/webmail?index=1, we can discuss it. Unless you or your host have added some specific restriction associated with /cgi-bin/, it should be simple enough to check the query sring with RewriteCond and the URI with RewriteRule.

Jim

daxal

9:01 pm on Jan 2, 2004 (gmt 0)

10+ Year Member



Thanks for the warm welcome =) Thanks for the ponter about followsymlinks, I think I read the pages for mod_rewrite and the other guides about 10 times now.

.htaccess:


RewriteEngine ON

RewriteCond %{QUERY_STRING} ^index=1$
RewriteRule ^webmail$ [example.com...] [R,L]

This is working now. I'd like to quell the query string. Currently you'll get [example.com...] because before rewriting the url was [webmail.example.com...]

jdMorgan

9:29 pm on Jan 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Scott,

To remove the query string, just add a "?" at the end of your substitution - It will remove the query, but will not "show" in the user's browser.

 
RewriteRule ^webmail$ http://www.example.com/? [R,L]

Jim