dongmei9020 2018-09-15 10:19
浏览 332

重定向到另一个URL,将其写入自己的URL

Very probably this is impossible, but I want to ask it, just in case.

I have a database in which I save some numbers (1, 2, 3...).

I have a .php page from which I read the numbers. I concat those numbers to a string for getting a full URL. For exmaple:

$intArticle = $row["article"];
$strURLBase = "example.com/index.php/"
$strLink = $strURLBase . $intArticle;

//And I get "example.com/index.php/1"

But now, there is an exception in which the URL points to an external website, so my code is not valid for now.

I know how to fix it in .php, but I would like to know if it is possible to make the redirect directly inside the URL, saving the properly string inside the database. For example:

$intArticle = $row["article"];  //In this case, the value of $row["article"] could be, for example, "http://www.externalweb.com"
$strURLBase = "example.com/index.php/"  //This part should be ignore inside the URL
$strLink = $strURLBase . $intArticle;

//I would get "example.com/index.php/http://www.externalweb.com"

Is there any kind of instruction that I could write inside the URL (that I would save into the database and then I would concat to $strURLBase) that redirects to another URL? For example:

example.com/index.php/!$%&_redirec_to("http://www.externalweb.com")

I don't want to call any PHP function from the URL for the redirection. In fact any PHP code shouldn't be executed. Everything should be inside the URL.

  • 写回答

1条回答 默认 最新

  • dota220141003 2018-09-15 10:29
    关注

    Try this:

    if (!is_numeric($intArticle))
    {
    header("Location: ".$strLink."");
    exit;
    }
    // your site will continue here, if the article is a number
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺