3

I'm trying to get this htaccess code to work:

<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 is enabled, but I've been told that mod_proxy is not enabled/available on Litespeed.

Is there a PHP workaround to running this?

Thanks

Simon East
  • 55,742
  • 17
  • 139
  • 133
Roger
  • 63
  • 6

1 Answers1

2

I was just trying the same thing on LiteSpeed and found your post. The only way I could achieve the proxying was via a simple one-line PHP script.

<?= file_get_contents('http://example.com/');

So to do what you're doing, it would be something more like this...

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^fld/(.*) proxy.php?fld=$1 [QSA,last]
  RewriteRule ^?$ proxy.php [QSA,last]
</IfModule>

And in proxy.php:

<?= file_get_contents(
      'http://example.com/' 
      . '?fld=' . $_GET['fld']
      . '&remoteaddr=' . $_SERVER['REMOTE_ADDR']
);

I hope that makes sense. If your hosting provider happens to block remote URLs in this manner, you might need to use curl which is a bit more code.

Simon East
  • 55,742
  • 17
  • 139
  • 133