我有一個網址縮寫腳本。有一個'forward.php'文件,用於在查詢縮短時重定向查詢。但在這個文件中,我想顯示一些文字或廣告前5-10秒重定向到原來的網址。執行一段時間後的PHP程序
我也嘗試睡眠(),刷新()和所有和沒有幫助。
謝謝。
代碼:
<?php
ob_start();
require("lib/config.php");
require("lib/common.php");
if(isset($_SERVER['QUERY_STRING'])){
$i = $_SERVER['QUERY_STRING'];
}else{
$i = $_SERVER['REQUEST_URI'];
$i = str_replace("/","",$i);
}
$suffix = $i{0};
$result = mysql_query("SELECT id,url FROM urls WHERE short_url = '$i'",DBH) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
$id = $row['id'];
$url = $row['url'];
mysql_query("UPDATE urls SET hits=hits+1 WHERE id = '{$id}'",DBH);
if ($_SESSION['config']['bar'] == true)
{
$meela_urllow = stripslashes(str_replace(",", "%2C", $url));
$meela_urllow = strtolower($meela_urllow);
if ((strpos($meela_urllow, "youtube")))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
if ((strpos($meela_urllow, "facebook")))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
if ((strpos($meela_urllow, "google")))
{
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
} else {
header('HTTP/1.1 301 Moved Permanently');
header("Location: ".stripslashes(str_replace(",", "%2C", $url)));
}
exit;
}
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://".$_SESSION['config']['domain']);
exit;
?>
,但我無法使用, 的stripslashes(str_replace函數( 「」, 「%2C」,$ URL)) 刷新標題。 – Rohan
@Rohan爲什麼不呢?如果url被編碼,那麼你沒有問題 –