0

I have a an old and a new site with 2 different urls, I'm trying to redirect the old urls to the new one with the proxy [p] flag. It works as expected, but it's landing in the wrong virtual host because it has the old url as host.

Sites:

  • myoldsite.com
  • mynewsite.com

Redirects:

RewriteRule ^(.*)/testtest$ https://mynewsite.com/content/testtest? [P]

The redirect should only trigger if i'm opening myoldsite.com, not when i'm visiting mynewsite.com.

The request is successfully redirected, but it uses the VirtualHost configuration of myoldsite.com because the host is set to it. I need it to be set to mynewsite.com to use the correct VirtualHost.

How could I achieve this?

MrWhite
  • 12,647
  • 4
  • 29
  • 41
NthDegree
  • 101
  • [[P](https://httpd.apache.org/docs/current/rewrite/flags.html#flag_p)] is not a redirect as such, it's a proxy. It should hit both virtual hosts. You coul try the [ProxyPass](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass) directive instead, but it's still proxying rather than redirecting, and so should still hit both virtual hosts. – Smock Jul 22 '20 at 18:14
  • Where exactly are you putting that "redirect" directive? How are your vHosts configured? (Why are you _proxying_ the request?) – MrWhite Jul 23 '20 at 23:51

0 Answers0