【问题标题】:mod_proxy using .htaccess on LiteSpeed在 LiteSpeed 上使用 .htaccess 的 mod_proxy
【发布时间】:2013-05-03 16:21:31
【问题描述】:
我正在尝试让这个 htaccess 代码工作:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^fld/(.*) http://example.com/fld/$1?proxy=http://example.com [P]
RewriteRule ^/?$ http://example.com/fld/app/cobra/847?remoteaddr=%{REMOTE_ADDR}&proxy=http://mydomain.com/customfolder [QSA,P]
</IfModule>
mod_rewrite 已启用,但有人告诉我 mod_proxy 在 Litespeed 上未启用/可用。
是否有 PHP 解决方法来运行它?
谢谢
【问题讨论】:
标签:
php
apache
.htaccess
mod-proxy
litespeed
【解决方案1】:
我只是在 LiteSpeed 上尝试同样的事情并找到了您的帖子。我可以实现代理的唯一方法是通过一个简单的单行 PHP 脚本。
<?= file_get_contents('http://example.com/');
所以要做你正在做的事情,它会更像这样......
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^fld/(.*) proxy.php?fld=$1 [QSA,last]
RewriteRule ^?$ proxy.php [QSA,last]
</IfModule>
在proxy.php:
<?= file_get_contents(
'http://example.com/'
. '?fld=' . $_GET['fld']
. '&remoteaddr=' . $_SERVER['REMOTE_ADDR']
);
我希望这是有道理的。如果您的托管服务提供商碰巧以这种方式阻止了远程 URL,您可能需要使用 curl 代码。