【发布时间】:2020-08-09 21:34:57
【问题描述】:
这可能是一个非常基本的问题,我什至不知道该怎么问。我有顶级列表网站,人们可以通过访问我的网站的人获得“输出”数字。
如果用户使用“http://”添加网站,则一切正常,但是,如果用户使用“https://”添加网站,则链接不起作用。
链接将简单地以 'https//' 形式打开。但冒号不会出现在 HTTPS 的基本 URL 中。因此链接无法正确打开。
有谁知道我如何使用preg_matches 来解决这个问题?
if(isset($_GET['action']) && $_GET['action'] == "out" && !empty($_GET['key']))
{
//echo "<pre>";
$site = ORM::for_table('topsite')->where_equal('hash_key',$_GET['key'])->find_one();
//print_r($site);
//echo $site->url;die();
$count = ($site->hits_out) + 1;
//echo $count;
$query = ORM::get_db()->prepare("update `topsite` set hits_out='".$count."' where id='".$site->id."'");
if(!preg_match('/http:/',$site->url))
{
$site->url = "http://".$site->url;
}
if( $query->execute() )
{
header("Location:$site->url");
}
else
{
header("Location: $base_url");
}
exit;
【问题讨论】:
标签: php url https preg-match out