The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Apache Alias for all domains on the server

Discussion in 'EasyApache' started by Louisvdw, Aug 7, 2013.

  1. Louisvdw

    Louisvdw Member

    Joined:
    Jun 23, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    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?
     
  2. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    You can add it in "Pre VirtualHost Include",
    WHM-> Service Configuration-> Apache Configuration-> Include Editor
     
  3. Louisvdw

    Louisvdw Member

    Joined:
    Jun 23, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Seems like this is what I was looking for. EasyApache: Changes Contained Within a VirtualHost Directive Include Files
    There is a section on Includes for all VirtualHost containers.

    - - - Updated - - -

    Thank you quitFinn. Any changes I made there only applied to the main server URL and not to all domains.
     
  4. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    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.
     
    #4 quietFinn, Aug 7, 2013
    Last edited: Aug 7, 2013
  5. Louisvdw

    Louisvdw Member

    Joined:
    Jun 23, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    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...
     
  6. Louisvdw

    Louisvdw Member

    Joined:
    Jun 23, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    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.
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page