homepage Welcome to WebmasterWorld Guest from 54.227.146.68
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Mailman redirect syntax
How to effect redirects based on hostname
byrnejb




msg:1503685
 7:44 pm on Apr 18, 2005 (gmt 0)

I am been googling for a straightforward description of how to translate a hostname into a directory based redirect so that calls to [mailman.domain.tld...] have the same effect as calls to [mailman.domain.tld...]

As shipped, mailman injects a file called mailman.conf into /etc/httpd/conf.d. This file contains the following:

# httpd configuration settings for use with mailman.
#

ScriptAlias /mailman/ /usr/lib/mailman/cgi-bin/
<Directory /usr/lib/mailman/cgi-bin/>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

Alias /pipermail/ /var/lib/mailman/archives/public/
<Directory /var/lib/mailman/archives/public>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

# Uncomment the following line, replacing www.example.com with your server's
# name, to redirect queries to /mailman to the listinfo page (recommended).

RedirectMatch ^/mailman[/]*$ [mailman.domain.tld...]

# End of mailman.conf

What I want is that browser calls to [mailman.domain.tld...] or [mailman.domain.tld...] or [mailman.domain.tld...] are are all mapped to [mailman.domain.tld...] and that the appropriate pages are displayed. I have read the various apache documation on rewritting and I have dinked around with various permutations of Redirect, RedirectMatch, RewriteCond & RewriteRule and all I have managed to do is cause endless loops.

I would greatly appreciate it if someone could show me the simplest way to accomplish this. I would also appreciate having the various steps explained as to how they work together so that I will not have to burden you with similar requests in future.

 

jdMorgan




msg:1503686
 9:19 pm on Apr 18, 2005 (gmt 0)

byrnejb,

Welcome to WebmasterWorld!

This site search [google.com] should turn up several threads to get you going.

Jim

byrnejb




msg:1503687
 2:02 am on Apr 19, 2005 (gmt 0)

Thank you for the references. I have not discovered anything in them that appears pertinent that I have not already tried. So, after beating my head against the wall I tried this:

RewriteEngine on
RewriteLog "/var/log/httpd/rewrite_log"
RewriteLogLevel 9

RewriteRule ^/mailman[/]*$ [mailman.halisp.net...] [L,R]

and commented out:

# RedirectMatch ^/mailman[/]*$ [mailman.halisp.net...]

Which acheived the same results and avoided the looping problem that I created by trying to mix the two approaches without really understanding what I was doing.

Now what I have discovered is that, because mailman.domain.tld is not configured as a virtual host and therefore does not have a document root and therefore cannot possess an index.html file, the default welcome.conf is trapping calls to mailman.domain.tld and rewriting the HTTP_HOST to the full canonical name of the server. This prevents this syntax from working:

# RewriteCond %(HTTP_HOST) ^mailman\.(.*)\.(..+)\.(..+)(\?)$ [NC]
# RewriteRule - [mailman.domain.tld...] [L,R]

What I need is some way of:

a. Avoiding the welcome.conf trap for this specific url.

b. parsing the original http request containing the unaltered name.

I tried this:

# RewriteCond %(SCRIPT_URI) ^mailman\.(.*)\.(..+)\.(..+)(\?)$ [NC]

but got caught by welcome.conf again. I tried setting up a virtual host for mailman.domain.tld but this created permissions problems, probably because I did not set the appropriate directory and scriptaliases. I suppose that I will eventually get this to work but it seems an awfully large amount of work to simply get [mailman.domain.tld...] to give the same result as [mailman.domain.tld...]

byrnejb




msg:1503688
 1:09 pm on Apr 19, 2005 (gmt 0)

Is there a way to force display of the contents of enviroment variables into the rewrite log file? I think that I would have a much great apprecaitiong of what is going on if I could see what is being checked.

Specifically HTTP_HOST

byrnejb




msg:1503689
 2:44 pm on Apr 19, 2005 (gmt 0)

After pulling my hair out and distressing my collegues in the next office with the deprecations I heaped upon my hapless workstation, I have obtained the results I wanted .

This may be of interest to other mailman users so I will post the results here.

The situation is this: A single server with multiple IP addresses and related hostnames acts as a mailman server. Mailman is a mailing list manager with a builtin web archive and subscription management system written in php. As shipped it injects a file called mailman.conf into /etc/httpd/conf.d that uses mod_alias to redirect traffic of the form [host.domain.tld...] to run the php scripts necessary to provide the management and archive service. The RedirectMatch statement used to effect this is:

RedirectMatch ^/mailman[/]*$ [example.com...]

However, this arrangment is awkward in that it requires a URL in the form [host.domain.tld...] to reach the mailman web interface. What is desired is that a URL in the form [mailman.domain.tld...] achive the same result.

Solution. The key to this lies in removing the default mailman.conf file and setting up a virtual host configuration that contains the directives in mailman.conf and provides two rewrite rules specifically tailored to the mailman virtual host. The first directive produces the same effect as the default RedirectMatch in mailman.conf:

RewriteRule ^/mailman[/]*$ [mailman.example.com...] [L,R]

The second provides the identical effect if the user simply uses the host name (mailman.example.com).

RewriteRule ^/$ [mailman.example.com...] [L,R]

The [L,] flag tells the rewrite engine to stop processing with this ruleset. The [,R] tells it to process the redirect without stripping the host part.

The entire virtual host configuration file follows:

<VirtualHost mailman.example.com>
DocumentRoot /var/lib/mailman/archives/public
ServerName mailman.example.com

ScriptAlias /mailman/ /usr/lib/mailman/cgi-bin/

<Directory /usr/lib/mailman/cgi-bin/>
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

Alias /pipermail/ /var/lib/mailman/archives/public/

<Directory /var/lib/mailman/archives/public>
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory "/var/lib/mailman/archives/public">
Options +Indexes +FollowSymLinks
Order allow,deny
allow from all
</Directory>

RewriteEngine on
RewriteLog "/var/log/httpd/rewrite_log"
RewriteLogLevel 0

RewriteRule ^/mailman[/]+$ [mailman.example.com...] [L,R]

RewriteRule ^/$ [mailman.example.com...] [L,R]

</VirtualHost>

Now what I need to do is to find out how one disguises the internal URI so that calls to mailman.example.com only display [mailman.example.com...] in the address bar of the browser and not [mailman.example.com...]

But the essential part is working now.

P.S.

One more thing. Do not forget that this change may require that mm_cfg.py be altered to use the hostname alias mailman.example.com rather than the fqdn of the host and mailman restarted. Otherwise the internal links to the archives may not work.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved