【问题标题】:How can I replace original base URL to my custom URL?如何将原始基本 URL 替换为我的自定义 URL?
【发布时间】:2020-07-28 19:05:48
【问题描述】:

当有人转到 mydomain.com 时,我只想重命名为 hellodomain.com 基本 URL 而无需刷新。这意味着 mydomain 和 hellodomain 之间没有关系。所以无论你什么时候去,你都会看到 hellodomain 而不是 mydoamin。

是否可以使用javascript?如果那我该怎么做呢?

【问题讨论】:

  • 你做不到。这是一个安全风险,所以浏览器会阻止它。您只能重定向到域,但不能在不重新加载页面的情况下更改它。

标签: javascript url redirect routing url-routing


【解决方案1】:

在 javascript 级别不可能

【讨论】:

    【解决方案2】:

    我们可以使用 PHP 解决这个问题。

    $handle = curl_init();
     
    $url = "https://example.com";
     
    // Set the url
    curl_setopt($handle, CURLOPT_URL, $url);
    // Set the result output to be a string.
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
     
    $output = curl_exec($handle);
     
    curl_close($handle);
     
    print_r($output);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-24
      • 2012-07-27
      • 1970-01-01
      • 1970-01-01
      • 2018-12-25
      • 1970-01-01
      • 2022-07-18
      相关资源
      最近更新 更多