Htaccess proxy redirect for root and only root

I am trying to redirect only the root domain (not its subfolders) to a different url without changing the address. I am using .htaccess and redirect with the [P] flag, which works fine for subdirectories, but not for the root.

When writing the following .htaccess everything works fine, but in a "regular" redirect and no proxy:

RewriteEngine on
Rewriterule ^$ http://mysubdomain.mydomain.com/ [R,L]

      

When upgrading to mod_proxy, it doesn't work (doesn't redirect without error):

RewriteEngine on
Rewriterule ^$ http://mysubdomain.mydomain.com/ [P]

      

It is important for me to keep the original address in the browser address bar. any idea?

thank

+3


source to share


1 answer


It probably doesn't work because the rule doesn't apply. In most cases, root is not empty, but contains a request for index.html or default.html. Try this snippet:



RewriteEngine  on
RewriteRule    "default.html"  "http://mysubdomain.mydomain.com/"  [P]

      

+5


source







All Articles