我想用PHP來創建一個重定向,從一個url引數中捕捉關鍵,并改寫它的相關值,例如:
https://somewhere.com/folder/?a_param=123
to
https://somewhere_else.com/?b_param=123
希望能在此為初學者提供任何指導。
uj5u.com熱心網友回復:
一般來說,在PHP中你可以像這樣重定向:
header("Location:"/span> . $somewhere)。)
exit。
如果你有一個名為rd.php的檔案,你將使用這樣的代碼:
https://somewhere.com/folder/rd.php?a_param=123
在rd.php中
<?php
$param = $_GET['a_param'/span>]。
header("Location: https://somewhere_else/?b_param={$param}") 。
exit。
如果你想實作https://somewhere.com/folder/?a_param=123,也就是說你不想要rd.php部分,你將需要apache2或你使用的任何webserver的一些幫助。你可以使用Apache mod_rewrite來完成這個任務。
# Put this in document_root/folder
# ...htaccess
RewriteCond %{REQUEST_FILENAME}! !-d
RewriteCond %{REQUEST_FILENAME}! !-f
RewriteRule ^(.*)$ rd.php [QSA,L)
uj5u.com熱心網友回復:
使用php頭檔案
header('Location: https://somewhere_else.com/?b_param='/span> . $_GET['a_param'])。)
exit()。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/320519.html
標籤:
