开发者

PHP Curl & htaccess

开发者 https://www.devze.com 2023-02-16 15:01 出处:网络
i have a question about PHP curl & .htaccess. My index.php file: <?php if(!isset($_GET[\'q\'])){ }

i have a question about PHP curl & .htaccess.

My index.php file:

<?php
      if(!isset($_GET['q'])){
     } 
      else {
     $q=$_GET['q']; 
     }
    $url = "http://81.83.192.124:8080/".@$q;


    $ch = curl_init();

    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt ($ch, CURLOPT_REFERER, $url);
    $result = curl_exec($ch);

    curl_close($ch);

    print $result;
 ?>

My .htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule ^([abc][^/]+) index.php?q=$1

The intentions is, when i go to http://example.org/NL/ i go with the curl to: http://81.83.192.124:8080/NL/

So far i am, 开发者_运维技巧but when i click on a link, i doesn't work further. Who can help me?


So your code is acting as a proxy of sorts for 81.83.192.124:8080? You'll run into a few issues. First, links with absolute paths would have to be rewritten. Second, you'll have to capture cookies in both directions if the underlying site requires them to work.


I think your issue is here...

RewriteRule ^([abc][^/]+) index.php?q=$1

should be more like this...

RewriteRule ^([abc][^/]+)/$ index.php?q=$1

see if that works for you

0

精彩评论

暂无评论...
验证码 换一张
取 消