You cannot use a ProxyPass in an htaccess file. The documentation says it is only applicable in the context: Context: server config, virtual host, directory which excludes htaccess (you can't have a <Directory> block in htaccess). However, you can use a ProxyPassReverse to internally rewrite the Location field of proxied requests that cause a redirect. You'll just need to use mod_rewrite's P flag to proxy instead of ProxyPass . So something like:
Just to be clear, you cannot use ProxyPassorProxyPassReverse in the htaccess file, but you can use ProxyPassReverse with mod_rewrite rules that utilize the P flag.
2条答案
按热度按时间mlmc2os51#
You cannot use a
ProxyPass
in an htaccess file. The documentation says it is only applicable in the context:Context: server config, virtual host, directory
which excludes htaccess (you can't have a
<Directory>
block in htaccess). However, you can use aProxyPassReverse
to internally rewrite the Location field of proxied requests that cause a redirect. You'll just need to use mod_rewrite'sP
flag to proxy instead ofProxyPass
. So something like:Just to be clear, you cannot use
ProxyPass
orProxyPassReverse
in the htaccess file, but you can useProxyPassReverse
with mod_rewrite rules that utilize theP
flag.8i9zcol22#
您不能使用ProxyPassReverse,但是如果您能够在HTML从源服务器返回时重写它,则可以模仿它。
请看我的文章here。