如何在 htaccess 中将子文件夹重定向为代理?

How to redirect subfolder as proxy in htaccess?

我在 localhost:63837 上安装了应用程序 运行,我想代理来自 https://www.domain.com/isso

的请求

这些是我的方法:

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

通常我会调整 httpd-vhost.conf 但在这种情况下,我不能在我的主机 (uberspace) 上这样做。

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

此外,我不喜欢为此使用子域。

您的第二种方法几乎是正确的(事实上,在 .conf 文件中完全可以使用)。

在每个目录上下文中(Directory.htaccess),Pattern 仅与部分路径匹配:规则所在的目录路径定义在比较之前从路径中删除 - 直到并包括尾部斜杠!。 删除的前缀总是以斜杠结尾,这意味着匹配发生在 never 有前导斜杠的字符串。

因此:

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