m i l e s wrote:
If I have the following series of urls:
webmail.theusersdomain.com
webmail.somedomain.com
webmail.myuserdomain.com
webmail.etc.com
Instead of adding hostdirections in the apache conf file....I was
thinking a mod_rewrite rule would do the trick rather nicely....what I
thought of was this:
RewriteEngine on
RewriteRule ^webmail\.[a-z]+\.com$ webmail\.[a-z]+\.com\:7080/scripts/
webmail.exe
Part of the reason mod_rewrite is such a bear is that it performs (at
least) two completely different functions:
--internal redirects - where the URL in the user's browser stays the
same but the http response come from someplace other than the
directory/file portion of the url BUT still comes from the same domain
(and server).
--external redirects - where the http response is a redirect telling the
browser to go to another URL completely. (Thus the URL changes in the
user's browser.)
What you are proposing above is an external redirect. You are changing
the domain name portion of the URL (by changing the port). You'll have
to show that port number in the user's browser. I have a hunch you were
trying to avoid that.
(Your RewriteRule is also in error:
First of all: The left hand side can't refer to a domain name but only
to the file portion of the URL. The right hand side can include a domain
name, and doing do makes it a redirect. (To indicate a domain name, you
use either the 'http://' prefix or use a [R] redirect directive at the end.)
Secondly, even if you could include domain names, your regex is way off:
I think you meant to use regular parentheses () around the second level
domain portion of the URL so you could reuse it in the right hand side.
And the right hand side should not be a regular expression at all but
should use a $1 symbol to show where the parenthesized portion from the
left hand side should go.
)
And lastly, would this rule live in the httpd.conf file or would this
rule live somewhere else ????
It can live in either the httpd.conf or the .htaccess files.
Or if I miss my guess would this rule have to live in a .htaccess file
in EVERY domain_directory that I host ?
And remember that you are defining new third level domains for each of
your second level domains. That may require some DNS work.
Within Apache, you could have a single virtual server for all your
webmail third level domains:
ServerName webmail.domain1.com
ServerAlias webmail.domain2.com
etc.
Then a single rewrite directive could apply to all those domains.
But it sounds like you are running your webmail on a different instance
of Apache, so you will have to do external redirects.
If you are using the different port to address a second host server
where your mail server lives, bear in mind that webmail (or at least
Squirrelmail) doesn't have to run on the same machine as the mailserver.
Sorry to be so long winded. Hope that helps.
John
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
" from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]