【问题标题】:Apache HTTPD: Proxy url pattern to another serverApache HTTPD:到另一台服务器的代理 url 模式
【发布时间】:2013-11-13 02:51:56
【问题描述】:

我使用 apache HTTPD 服务器作为前端,并希望将某些 url 重定向到本地运行的另一台服务器。

比如我想要:

http://www.example.com/index.php 加载位于/var/www/index.php 的文件 http://www.example.com/products/*代理到另一个本地服务器和 url,例如http://127.0.0.1:9000/

我正在尝试在根 www 目录中编写一个简单的 .htaccess 文件,但每当我执行此简单示例时,它都会在 httpd 日志中给我一个 File does not exist 错误:

.htaccess:

RewriteEngine On
RewriteRule ^test.html$ /index.php

我试图查找此错误,但所有在线参考资料都已过时。例如,mod_rewrite error: [client 127.0.0.1] File does not exist 引用了 httpd.conf,它不再包含在 apache httpd 中。

有谁知道为什么mod_rewrite 不起作用?或者如何写一个重定向到另一个本地服务器?

【问题讨论】:

    标签: apache .htaccess mod-rewrite proxy


    【解决方案1】:

    要反向代理,您需要使用P 标志:

    RewriteRule ^/?products/(.*)$ http://127.0.0.1:9000/$1 [L,P]
    

    您需要加载 mod_proxy 才能使其工作,否则它将重定向浏览器。

    【讨论】:

      猜你喜欢
      • 2010-11-27
      • 2018-01-20
      • 1970-01-01
      • 2013-12-20
      • 1970-01-01
      • 2014-02-12
      • 2011-04-05
      • 2012-01-25
      • 1970-01-01
      相关资源
      最近更新 更多