Apache HTTPD:代理url模式到另一台服务器

时间:2013-11-13 02:51:57

标签: apache .htaccess mod-rewrite proxy

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

例如我想:

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

我正在尝试在根.htaccess目录中编写一个简单的www文件,但每当我执行这个简单示例时,它会在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引用了apache httpd。

中不再包含的httpd.conf

有谁知道mod_rewrite无效的原因?或者如何将重定向写入另一个本地服务器?

1 个答案:

答案 0 :(得分:1)

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

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

你需要加载mod_proxy才能使用,否则它会改为重定向浏览器。

相关问题