Redirecting /webmail for a specific account

NetShapersInc

Member
Apr 13, 2012
22
1
51
cPanel Access Level
Root Administrator
Hi guys,

I want to redirect /webmail for a specific account.

To put it into perspective, we are a web development company who also hosts email for clients, and about half of our clients are on our cPanel box, and the other half are still on a colocated box. For the colo email clients, they would hit our domain: domain.com/webmail. We migrated our site to our cPanel box, and now the older clients can't use the webmail link (due to them not being migrated to the cPanel box).

Is there any way that we can choose not to forward them to the cPanel webmail link if the request is coming from that domain? I've searched endlessly on this forum and have not been able to find out any details that worked in our application.

Please note we own the WHM box so any manual file changes that need to be done can be done.

Server:
WHM 11.32.3 (build 23)
CENTOS 6.3 i686 VPS Optimized3
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
42
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
You would need to remove the ScriptAliasMatch line toward the top of /usr/local/apache/conf/httpd.conf and then configure it on a per VirtualHost basis using include. The line looks like the following:

Code:
ScriptAliasMatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
After removing the line, copy a backup of httpd.conf, distill the changes, rebuild it and restart it:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak120801
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
At that point, try adding the line to /usr/local/apache/conf/userdata/std/2/username locations for individual accounts that need it. You'll have to create the path /usr/local/apache/conf/userdata/std/2/username and replace username with the cPanel username. You'll also have to create another one in /usr/local/apache/conf/userdata/ssl/2/username location. The file could be named webmail.conf or whatever you prefer ending in .conf

We have documentation on using includes such as these at this location:

Changes Contained within a VirtualHost Directive

Thanks!
 

NetShapersInc

Member
Apr 13, 2012
22
1
51
cPanel Access Level
Root Administrator
Tristan, one quick question -- how can I do a AddType line into the root apache config? I want to parse HTML through PHP, (run PHP files that are marked as .htmls), and I needed to do this with the login form.

Is there any way to do this?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
42
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
You would be better off adding this to /usr/local/apache/conf/includes/pre_virtualhost_global.conf file. You can see the syntax you would use for an AddType in /usr/local/apache/conf/php.conf file.

Please do not place the AddType into /usr/local/apache/conf/php.conf file itself, as that file is wiped whenever EasyApache is recompiled and the PHP handler is selected (or whenever you change the PHP handler in WHM > Apache Configuration > PHP and SuExec Configuration area).

Thanks!
 

NetShapersInc

Member
Apr 13, 2012
22
1
51
cPanel Access Level
Root Administrator
Tristan,

It still does not seem to be working. I put this line in the pre_virtualhost_global.conf: "AddType application/x-httpd-php .php .php3 .php4 .php5 .html", ran the distiller, rebuilt the httpd.conf file, and restarted apache, but to avail.

Any ideas on what could cause this? I even put it in the php.conf file just to see if it'd actually work, and that didn't either.
 

NetShapersInc

Member
Apr 13, 2012
22
1
51
cPanel Access Level
Root Administrator
# This file was automatically generated by the Cpanel PHP Configuration system
# If you wish to change the way PHP is being handled by Apache on your system,
# use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
#
# Manual edits of this file will be lost when Apache is updated.


# LibPHP5 configuration
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml

# End of autogenerated PHP configuration.
Or with the extra line:

# This file was automatically generated by the Cpanel PHP Configuration system
# If you wish to change the way PHP is being handled by Apache on your system,
# use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
#
# Manual edits of this file will be lost when Apache is updated.


# LibPHP5 configuration
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php .php .php3 .php4 .php5 .html

# End of autogenerated PHP configuration.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
42
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
You'll have to revise the existing line instead:

AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml .html

Otherwise, you can just try adding it as an include with only .html for the line in the include you are trying. If pre_virtualhost_global.conf doesn't work, go ahead and try the other include files one by one to see which does work.

Of note, you only need to restart Apache. You don't have to distill or rebuild it when using /usr/local/apache/conf/includes files. Those are already included in httpd.conf by default.