Apache Alias for all domains on the server

Louisvdw

Member
Jun 23, 2011
13
0
51
I am trying to set up an Alias for Apache that will work on all domains on my server. Something similar to the /cpanel /whm and /webmail redirect that cPanel has by default.

I know I can add an Alias in the include for each user/domain by adding a .conf file in the /usr/local/apache/conf/userdata/std directories, but there must be a easier way that will work globally on any domain, even a new one.

Example:
I want to add an alias that should work for any domain on the server:
Alias /Autodiscover/Autodiscover.xml "/var/www/Autodiscover/Autodiscover.php"

so that
http://mydomain.com/Autodiscover/Autodiscover.xml
http://anotherdomain.com/Autodiscover/Autodiscover.xml
http://moredomain.com/Autodiscover/Autodiscover.xml
all get redirected to /var/www/Autodiscover/Autodiscover.php

Is this possible?
 

quietFinn

Well-Known Member
Feb 4, 2006
1,306
132
193
Finland
cPanel Access Level
Root Administrator
You can add it in "Pre VirtualHost Include",
WHM-> Service Configuration-> Apache Configuration-> Include Editor
 

Louisvdw

Member
Jun 23, 2011
13
0
51

quietFinn

Well-Known Member
Feb 4, 2006
1,306
132
193
Finland
cPanel Access Level
Root Administrator
Thank you quitFinn. Any changes I made there only applied to the main server URL and not to all domains.
It is working in all of our servers.

EDIT:
After testing this I noticed that it only works for a directory, not for a file, i.e:
Alias /Autodiscover/ /var/www/Autodiscover/

would work.
 
Last edited:

Louisvdw

Member
Jun 23, 2011
13
0
51
It seems like you are correct. When only directory is used it does work for all domains, but if you match a file then it only works for the server url.

I did manage to get some sort of working option by using this:
AliasMatch (?i)/Autodiscover/.* /usr/share/Autodiscover/Autodiscover.xml

The check is still only against a folder which then apply the alias to all domains.
The problem is that I have to use a static file as my php file does not want to work (I know the php script itself work as I tested it on the server url, but it does not work through all the domains.

I would love to get the matching of a file working for all domains though...
 

Louisvdw

Member
Jun 23, 2011
13
0
51
It seems like the reason the php file does not work is because the server is using suPHP and the file can only be owned by one account.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,228
463
Hello :)

This post is intended for changing the webmail alias, but it may be helpful to you as an example:

Overwrite Webmail Alias

Thank you.