How to disable autodiscover/autodiscover.xml?

coldpumpkin

Registered
Jan 18, 2022
3
0
1
Portugal
cPanel Access Level
Reseller Owner
Hello,

Sorry in advance if this is the wrong section for this, I thank in advance if it gets moved.

From my understanding if we set "Remote Mail Exchanger" under "Email Routing", it's supposed to stop autodiscover/autodiscover.xml from being active. I could be wrong though, I read this here. If that's the expected behaviour, it's not working right now.

Basically I need the first layer of autodiscover to be autodiscover.domain.com instead of domain.com/autodiscover/autodiscover.xml.

My client created an A record for domain.com to my server, so I'm handling their website and they handle everything else, including autodiscover.domain.com, which is pointing to the right direction. My client is working with Microsoft Exchange and they say that domain.com/autodiscover/autodiscover.xml shouldn't be active because it's creating a conflict when adding e-mails to their phones.

I tried creating a redirect through htaccess but it's not working, I'm assuming redirecting autodiscover.xml isn't possible. The only way I managed to have it redirected was by adding the following to "Post VirtualHost Include" in Apache (source):

Code:
RedirectMatch (?i)/Autodiscover/Autodiscover.xml http://autodiscover.domain.com
However I have to insert the domain in the destination, that's probably not going to end well since this is not per account.

This problem is similar to the one this guy was having 5 years ago: https://features.cpanel.net/topic/disable-autodiscover-on-domains-set-to-remote-mx-servers

Can anyone help me here?
 
Last edited:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
12,497
1,967
363
cPanel Access Level
Root Administrator
@coldpumpkin - the details in that article are not correct. It could certainly affect how the autodiscover tool works, but it wouldn't change it. Details on the Email Routing tool in cPanel can be found here:


Disabling the option server-wide would keep the DNS records from being created in the future. If you don't want the DNS records for a certain domain, using the DNS Zone Manager tool inside of cPanel to remove the specific records from the domain is the easiest per-domain way to remove those records.
 

coldpumpkin

Registered
Jan 18, 2022
3
0
1
Portugal
cPanel Access Level
Reseller Owner
Hi @cPRex, thank you for answering.

Disabling the option server-wide would keep the DNS records from being created in the future. If you don't want the DNS records for a certain domain, using the DNS Zone Manager tool inside of cPanel to remove the specific records from the domain is the easiest per-domain way to remove those records.
What DNS records would that be though? Please note I'm trying to get rid of domain.com/autodiscover/autodiscover.xml and not autodiscover.domain.com
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
12,497
1,967
363
cPanel Access Level
Root Administrator
Thanks for that clarification. Since that is the case, you don't want to make any DNS changes as that would disrupt the autodiscover subdomain.

cPanel includes the following entries by default in the Apache configuration file, which is why you found that editing .htaccess wasn't sufficient to make the change, but only an Apache include would partially take care of it.

Code:
<IfModule alias_module>
    ScriptAliasMatch ^/?controlpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
    ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
    ScriptAliasMatch ^/?kpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
    ScriptAliasMatch ^/?securecontrolpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
    ScriptAliasMatch ^/?securecpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
    ScriptAliasMatch ^/?securewhm/?$ /usr/local/cpanel/cgi-sys/swhmredirect.cgi
    ScriptAliasMatch ^/?webmail$ /usr/local/cpanel/cgi-sys/wredirect.cgi
    ScriptAliasMatch ^/?webmail/ /usr/local/cpanel/cgi-sys/wredirect.cgi
    ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi
    ScriptAliasMatch ^/Autodiscover/Autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi
    ScriptAliasMatch ^/autodiscover/autodiscover.xml /usr/local/cpanel/cgi-sys/autodiscover.cgi

    Alias /bandwidth /usr/local/bandmin/htdocs/
    Alias /img-sys /usr/local/cpanel/img-sys/
    Alias /java-sys /usr/local/cpanel/java-sys/
    Alias /mailman/archives /usr/local/cpanel/3rdparty/mailman/archives/public/
    Alias /pipermail /usr/local/cpanel/3rdparty/mailman/archives/public/
    Alias /sys_cpanel /usr/local/cpanel/sys_cpanel/

    ScriptAlias /cgi-sys /usr/local/cpanel/cgi-sys/
    ScriptAlias /mailman /usr/local/cpanel/3rdparty/mailman/cgi-bin/

</IfModule>
There's a good discussion about this at the following link:


and near the bottom one user recommends some potential edits to the configuration to workaround the issue you're experiencing. I haven't tested them on my side since we don't deal with Exchange, but it sounds like exactly what you're looking to do.