Change /webmail Redirect for One Domain

orty

Well-Known Member
Jun 29, 2004
109
0
166
Bend, Oregon
cPanel Access Level
Root Administrator
I have a client who is starting to use and outside mail service (google apps for domains, if you must know). They've become accustomed to going to domain.com/webmail to get the webmail login and they're hard folks to re-train, so I'd rather they just keep going there. However, that's hardcoded in httpd.conf server-wide to go to cPanel's webmail login.

Is there any way I can turn off that redirect for just this one domain so I can just create a webmail folder that has a redirect inside it to their new service's login (which is just http://mail.google.com/a/domain.com)?

Thanks!
-orty
 

misk0

Registered
Nov 30, 2004
4
0
151
Maybe you can try to redefine Alias "/webmail" for that domain within <virtualhost> tags?
 

orty

Well-Known Member
Jun 29, 2004
109
0
166
Bend, Oregon
cPanel Access Level
Root Administrator
In case anybody else is trying this, I put this in that particular domain's VirtualHost declaration:

Code:
ScriptAlias /webmail /home/user/public_html/email/index.cgi
ScriptAliasMatch ^/webmail/(.*) /home/user/public_html/email/index.cgi
So basically, I'm redirecting /webmail to a folder called "email" that has index.cgi in it. I'm basically copying the above code from the top of the httpd.conf file as that's what cPanel uses for its redirect for /webmail:
Code:
ScriptAlias /webmail /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/webmail/(.*) /usr/local/cpanel/cgi-sys/wredirect.cgi
Inside that index.cgi file, I have a simple perl script that redirects to the proper page:
Code:
#!/usr/bin/perl
use CGI; 
my $q = CGI->new(); 
print $q->redirect( 
  -location => 'http://mail.google.com/a/domain.com', 
  -status => 302,
);
So far it seems to work. Thanks!
(edited this entry as I initially posted that it didn't work, but I had a typo in my perl code)
 
Last edited:

SageBrian

Well-Known Member
Jun 1, 2002
413
2
318
NY/CT (US)
cPanel Access Level
Root Administrator
cool. Thanks.

So, this would likely be a way to create a server wide redirect I assume.

I'm thinking of offering an alternative webmail option, with more customized options, and to get around that pesky port issue for those behind firewalls.

I'm planning on setting up Squirrelmail on an account, give it an SSL cert (self-signed might be good enough). This allows for access to mail thru port 80, and allows me to add and tweak features of SquirrelMail that wouldn't get over-written with a cpanel update.

Code:
ScriptAlias /supermail /home/supermail/public_html/email/index.cgi
ScriptAliasMatch ^/supermail/(.*) /home/supermail/public_html/email/index.cgi


Code:
#!/usr/bin/perl
use CGI; 
my $q = CGI->new(); 
print $q->redirect( 
  -location => 'https://supermail.hostname.com', 
  -status => 302,
);
I knew someone would share a solution.
Thanks buddy.