How to redirect subfolder as proxy in htaccess?

5.4k views Asked by At

I have isso app running on localhost:63837 and I'd like to proxy requests from https://www.domain.com/isso

These were my approaches:

RewriteRule https://www.domain.com/isso/(.*)$ http://127.0.0.1:63837/$1 [P] 
RewriteRule /isso/(.*)$ http://127.0.0.1:63837/$1 [P] 
RewriteRule /isso(.*)$ http://127.0.0.1:63837/$1 [P]

Normally I'd adjust httpd-vhost.conf but in this case I can't do that on my hoster (uberspace).

<Location "/isso">
  ProxyPass "http://127.0.0.1:63837"
  ProxyPassReverse "http://127.0.0.1:63837"
</Location>

Also, I don't like to use a subdomain for this.

1

There are 1 answers

1
Dusan Bajic On BEST ANSWER

Your second approach was almost correct (in fact, exactly that would work in .conf file).

In per-directory context (Directory or .htaccess), the Pattern is matched against only a partial path: the directory path where the rule is defined is stripped from the path before comparison - up to and including a trailing slash!. The removed prefix always ends with a slash, meaning the matching occurs against a string which never has a leading slash.

Therefore:

RewriteRule ^isso/(.*)$ http://127.0.0.1:63837/$1 [P]