I've recently received a request from the site owner to redirect our base domain to a specific landing page on a subdomain, which is working just fine. The problem is that he wants the URL to remain the same, so the user will see mydomain.com but go to sub.mydomain.com/index.php?landing
I did some research and found that the proper way to redirect a user while keeping the URL intact is to proxy the request, which, as far as I can tell, can be accomplished with the P flag in a RewriteRule. However, despite confirming that mod_proxy is indeed installed via WHM, the URL still gets rewritten to the landing page in the browser. Here's the relevant section of my .htaccess file for reference:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteRule ^(.*)$ http://sub\.mydomain\.com/index\.php\?landing/ [P]
This is an AWS server using WHM/cPanel on CentOS 7.8 with a standard LAMP stack. I feel like this is probably something simple that I'm overlooking, so hopefully someone can provide some insight. I've used mod_rewrite many times in the past, but I've never had to proxy a request like this.
ProxyPassReverse
in the server config. Is the main domain and subdomain pointing to different filesystems/servers? (If they are on the same filesystem then you may not need to proxy the request?)