I need to create a sub-directory mapping in the Apache server such that each request made to the path /another-path gets forwarded to https://some-website/another-path. How could I do this?

If the incoming request is on my server https://my-website/another-path. I want it forward to another server on https://some-website/another-path.

How can I do this?

  • Your question is not clear to me. Where is the exception? All requests should be proxy forwarded to the same backend, so ProxyPass directive is your solution. But what is the difference between the incoming request of /another-path and https://my-website/another-path. Are that different vhosts?
    – TRW
    Feb 18, 2021 at 11:52
  • @TRW What I want is this. A request https://example.com/this-path gets forwarded to https://example-1.com/.
    – Amanda
    Feb 18, 2021 at 13:33
  • @TRW Any help?.
    – Amanda
    Feb 22, 2021 at 11:09

1 Answer 1


Please have a look at https://stackoverflow.com/questions/1393706/how-to-use-a-different-path-name-in-proxypass-than-the-tomcat-context-name which is nearly the same problem but with Tomcat.

ProxyPass /this-pass/ https://example-1.com/
ProxyPassReverse /this-pass/ https://example-1.com/

Use ProxyPass. The problem is not the domain, the problem is the different location on the backend server. ProxyPass and ProxyPassReverse can handle that. If it isn't working out of the box, then try ´Rewrite` hack on the response.

RewriteEngine on
RewriteRule ^/$ /this-pass/ [R]
RewriteRule ^/(.*) /this-pass/$1 [P]

But I think, this isn't necessary (I didn't test that rewrite).

  • Could you help me understand your answer?
    – Amanda
    Feb 24, 2021 at 3:37
  • Maybe you need to update your question about - what do you need to understand? Do you know, how Apache works? Do you have access to the Apache configuration? What is your current configuration? I could explain, how reverse proxing works, but I'm not sure what you don't understand. When you know, how Apache2 config works and you can change it, did you try to use ProxyPass and tested it? What was the result? That would help me to improve the answer.
    – TRW
    Feb 25, 2021 at 8:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .