2

I found several other questions, but none is exactly what I'm trying to do.

I need to point www.mywebsite.com/certainfolder/blabla/?foo=bar To www.anotherwebsite.com/certainfolder/blabla/?foo=bar

So, if my website has a route to 'certainfolder', I need to point to this folder (with all other uri segments and get parameters), to another website.

Important is that the url remains www.mywebsite.com/certainfolder/blabla/?foo=bar It just has to take content from www.anotherwebsite.com, but cannot change the url.

I tried something like this, which is not working:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/certainfolder
RewriteRule ^/$ http://www.anotherwebsite.com/certainfolder/$1 [P,L]

I know i can use ProxyPass and ProxyPassReverse in the vhost conf file, but i cannot access this file, so i need to do it in the .htaccess

Is there any .htaccess specialist who can help me out?

jens_vdp
  • 594
  • 1
  • 4
  • 18
  • Possible duplicate of [How can I redirect to a different domain without changing the URL in the address bar?](https://stackoverflow.com/questions/987343/how-can-i-redirect-to-a-different-domain-without-changing-the-url-in-the-address) – Martin Dec 18 '17 at 10:38
  • No; what you're trying to do can not be done *just* in htaccess, – Martin Dec 18 '17 at 10:48
  • Possible duplicate of [Can ProxyPass and ProxyPassReverse work in htaccess?](https://stackoverflow.com/questions/12808506/can-proxypass-and-proxypassreverse-work-in-htaccess) – iainn Dec 18 '17 at 13:01

1 Answers1

0

Assuming the website does not redirect itself, it is possible using mod_proxy + mod_proxy_http ( / http2) RewriteEngine on RewriteRule ^certainfolder/$ http://www.anotherwebsite.com/certainfolder/$1 [P]

The [P] only works when mod_proxy is enabled, and for http mod_proxy_http is required.

mod_proxy allows to "proxy" requests from another resource to your own domain.

mod_proxy is only required on your own host, not on the remote part. mod_proxy_http is the part that handles http requests for mod_proxy. (because mod_proxy can also serve other protocols besides http, it's made modular). On a generic linux installation commandline, enter: a2enmod proxy proxy_http && service apache2 restart

twicejr
  • 1,319
  • 3
  • 13
  • 21
  • mod_proxy is only required on your own host, not on the remote part. mod_proxy_http is the part that handles http requests for mod_proxy. (because mod_proxy can also serve other protocols besides http, it's made modular). On a generic linux installation use `a2enmod proxy proxy_http && service apache2 restart` – twicejr Dec 18 '17 at 10:47