Apache Alias for all domains on the server - custom autodiscover file

Operating System & Version
Centos 7, litespeed 6.0.9
cPanel & WHM Version
WHM 11.108.0.14

ruonline

Registered
Mar 15, 2023
2
0
1
Melbourne
cPanel Access Level
Root Administrator
I'm trying to set up a custom alias for all domains on the server - a custom autodiscover setup, so that for all domains, the path "/autodiscover/autodiscover.xml" is sent to a file on the server "/home/ruonline/public_html/autodiscover.php"

This is exactly the question asked in the link below, but the answer is unclear, and the link in the discussion is dead.


After reading another forum post (link below), I've been able to do something similar, and set up a 301 redirect for this "/autodiscover/autodiscover.xml" path using the following code in Apache's Include Editor (pre main include):

RewriteOptions inherit
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} ^/autodiscover.xml
RewriteRule ^(.*)$ https://autodiscover.myotherdomain.tld/autodiscover/autodiscover.xml [R=301,L]



This redirect works, but I need to serve a file from the server (masked), rather than just redirect to a URL like this script does.

When I try to change the RewriteRule to:



RewriteRule ^(.*)$ /home/user/public_html/autodiscover.php



I get a 404 error.

Can anyone please help me with this?
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,163
2,410
363
cPanel Access Level
Root Administrator