導航:首頁 > 編程語言 > php請求轉發

php請求轉發

發布時間:2023-01-01 17:00:50

『壹』 php 怎麼簡單實現請求內容的完整轉發

可以在webserver層就做反向代理。具體你可以搜索apache 反向代理。或者nginx 反向代理。

『貳』 Thinkphp5項目在nginx伺服器部署

1,切換到nginx的配置目錄,找到nginx.conf文件

    cd   /usr/local/nginx/conf

    vim  nginx.conf

2,如果是單項目部署的話,只需要在nginx.conf文件裡面加上以下

server{

        listen 80;

        # 域名,本地測試可以使用127.0.0.1或localhost

        server_name www.zhangc.cn;

        # php項目根目錄

        root /home/data-www/blog;

        location /{

                # 定義首頁索引文件的名稱

                index index.php index.html index.htm;

                # 影藏入口文件

                if (-f $request_filename/index.html){

                            rewrite (.*) $1/index.html break;

                }

                if (-f $request_filename/index.php){

                            rewrite (.*) $1/index.php;

                }

                if (!-f $request_filename){

                            rewrite (.*) /index.php;

                }

                try_files $uri $uri/ /index.php?$query_string;

        }

        # PHP 腳本請求全部轉發到 FastCGI處理. 使用FastCGI協議默認配置.

        # Fastcgi伺服器和程序(PHP)溝通的協議

        .location ~ .*\.php${

                # 設置監聽埠

                fastcgi_pass 127.0.0.1:9000;

                # 設置nginx的默認首頁文件

                fastcgi_index index.php;

                # 設置腳本文件請求的路徑

                fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;

                # 引入fastcgi的配置文件

                include fastcgi_params;

                fastcgi_split_path_info ^(.+?\.php)(/.*)$;

                set $path_info $fastcgi_path_info;

                fastcgi_param PATH_INFO $path_info;

                try_files $fastcgi_script_name =404;

        }

}

3,如果多項目部署,就需要配置vhost

第一步:編輯nginx.conf文件,在最後加上     include    vhost/*.conf;

第二步:進入vhost文件夾,創建    域名.conf    文件,如創建一個:quanma.meyat.com.conf

第三步:編輯quanma.meyat.com.conf文件,內容如下:

        server

        {

                listen 80;

                server_name quanma.meyat.com;

                index index.html index.htm index.php default.html default.htm default.php;

                root /data/wwwroot/default/quanma/public/;

                #error_page 404 /404.html;

                location / {

                        index index.html index.php;

                        if (-f $request_filename/index.html){

                                rewrite (.*) $1/index.html break;

                        }

                        if (-f $request_filename/index.php){

                                rewrite (.*) $1/index.php;

                        }

                        if (!-f $request_filename){

                                rewrite (.*) /index.php;

                        }

                        try_files $uri $uri/ /index.php?$query_string;

                }

                location ~ [^/]\.php(/|$)

                {

                        # comment try_files $uri =404; to enable pathinfo

                        #try_files $uri =404;

                        fastcgi_pass 127.0.0.1:9000;

                        fastcgi_index index.php;

                        include fastcgi_params;

                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                        fastcgi_split_path_info ^(.+?\.php)(/.*)$;

                        set $path_info $fastcgi_path_info;

                        fastcgi_param PATH_INFO $path_info;

                        try_files $fastcgi_script_name =404;

                        #include fastcgi.conf;

                        #include pathinfo.conf;

            }

            location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

            {

                    expires 30d;

            }

            location ~ .*\.(js|css)?$

            {

                    expires 12h;

            }

            # Disallow access to .ht, .svn, .bzr, .git, .hg, .cvs directories

            location ~ /\.(ht|svn|bzr|git|hg|cvs) {

                    deny all;

            }

            #access_log /date/nginx/bmp.com.conf/access.log main;

}

『叄』 php curl如何直接轉發當前php接收的headersget請求如何直接轉發get參數post請求如何直接轉發post參數

本文實例講述了php使用CURL模擬GET與POST向微信介面提交及獲取數據的方法。分享給大家供大家參考,具體如下:
php CURL函數可以模仿用戶進行一些操作,如我們可以模仿用戶提交數據也可以模仿用戶進行網站訪問了,下面我們來介紹利用CURL模擬進行微信介面的GET與POST例子,例子非常的簡單就兩個:
Get提交獲取數據
/**
* @desc 獲取access_token
* @return String access_token
*/
function getAccessToken(){
$AppId = '1232assad13213123';
$AppSecret = '2312312321adss3123213';
$getUrl = 'htq.com/cgi-bin/token?grant_type=client_credential&appid='.$AppId.'&secret='.$AppSecret;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $getUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURL_SSLVERSION_SSL, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$data = curl_exec($ch);
$response = json_decode($data);
return $response->access_token;
}

post提交獲取數據
/**
* @desc 實現天氣內容回復
*/
public function testWeixin(){
$access_token = $this->getAccessToken();
$customMessageSendUrl = 'ht.qq.com/cgi-bin/message/custom/send?access_token='.$access_token;
$description = '今天天氣的詳細信息(從第三方獲取)。';
$url = ttpr.com/';
$picurl = 'her.com/';
$postDataArr = array(
'touser'=>'OPENID',
'msgtype'=>'news',
'news'=>array(
'articles'=>array(
'title'=>'當天天氣',
'description'=>$description,
'url'=>$url,
'picurl'=>$picurl,
),
),
);
$postJosnData = json_encode($postDataArr);
$ch = curl_init($customMessageSendUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postJosnData);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$data = curl_exec($ch);
var_mp($data);
}

例子相對來說比較簡單也沒有什麼好詳細分析的了,大家照抄就可以實現我們想要的功能了.

『肆』 php中我在資料庫中查詢出了用戶的信息,結果集是一個二維的數組,用什麼方法能更好的傳到下個頁面

我本來搞java的,看了php就一直在想怎麼實現請求轉發,如果有請求轉發你這個就不是個問題。網上有模擬實現java請求轉發的例子,不過寫的太長。樓上二位的方法都可以,session或者是改成字元串,不過我還想了一個辦法,你可以試試,我自己還沒來得及試,哈哈。
在php頁面裡面放一個form,弄一個hidden的input,轉發的時候把數組的值賦給input,然後用javascript調用form.submit,提交到下一個頁面。
java裡面表單什麼都可以傳的,php我剛學,不知道能不能用表單傳數組,應該沒問題吧,哈哈,試試看。

『伍』 php ,post轉發。 站點接到一個post信息,把這post信息轉發給另外的一個域名。

看你大頭照就知道你是 Drupal 同好(我也是 Drupal 模組開發者)

兩種方式:

  1. 透過 PHP post 方式去用表單操作,在從後端收到信息後判斷並轉址

  2. 透過 ajax 前端處理,當站點收到信息,在透過 ajax 去轉址

不懂可以私信問我詳細

『陸』 php怎麼響應客戶端發送http請求

http請求有get,post。
php發送http請求有三種方式[我所知道的有三種,有其他的告訴我]。
1. file_get_contents();詳情見:http://www.jb51.net/article/41833.htm
2. curl發送請求。
3. fsocket發送。
下面說使用curl發送。
首先環境需要配置好curl組件。
在windows中讓php支持curl比較簡單:
在php.ini中將extension=php_curl.dll前面的分號去掉,
有人說需要將php根目錄的libeay32.dll和ssleay32.dll需要拷貝到系統目錄下去。我實驗不拷貝也可以。
linux中,如果使用源碼安裝,需要在make 之前,./configure --with-curl=path,
其中,path是你的 libcurl庫的位置,比如你安裝libcurl庫之後,
path可能就是/usr/local/,libcurl可以是靜態庫,也可以是動態庫。
注意libcurl庫configure的時候,可以將一些不需要的功能去掉,
比如ssl , ldap等。在php configure的時候,會去檢查libcurl中某些功能是否被開啟,進而去相應地調整生成的php。

閱讀全文

與php請求轉發相關的資料

熱點內容
dvd光碟存儲漢子演算法 瀏覽:757
蘋果郵件無法連接伺服器地址 瀏覽:962
phpffmpeg轉碼 瀏覽:671
長沙好玩的解壓項目 瀏覽:142
專屬學情分析報告是什麼app 瀏覽:564
php工程部署 瀏覽:833
android全屏透明 瀏覽:732
阿里雲伺服器已開通怎麼辦 瀏覽:803
光遇為什麼登錄時伺服器已滿 瀏覽:302
PDF分析 瀏覽:484
h3c光纖全工半全工設置命令 瀏覽:141
公司法pdf下載 瀏覽:381
linuxmarkdown 瀏覽:350
華為手機怎麼多選文件夾 瀏覽:683
如何取消命令方塊指令 瀏覽:349
風翼app為什麼進不去了 瀏覽:778
im4java壓縮圖片 瀏覽:362
數據查詢網站源碼 瀏覽:150
伊克塞爾文檔怎麼進行加密 瀏覽:892
app轉賬是什麼 瀏覽:163