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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退