【问题标题】:Redirecting to domain root but storing the original url request重定向到域根但存储原始 url 请求
【发布时间】:2011-12-20 14:45:46
【问题描述】:

嗨,我想要做的是获取一个类似的网址:http://mydomain.com/google.com 并对其进行解析,以便它在 iframe 中打开 google.com。目标是能够在 iframe 中打开 mydomain.com 上的任何站点,但让用户使用 http://mydomain.com/<somesite> 提交他们想要的站点,例如:http://mydomain.com/youtube.com 将在 iframe 中打开 youtube。 问题是像这样将站点附加到 url 显然会返回 404 not found。我猜这里需要一些 htaccess 魔法,但我不擅长。

那么我该如何实现呢?

【问题讨论】:

    标签: php .htaccess url rewrite


    【解决方案1】:

    是的,你需要一个.htaccess 魔法。试试:

    RewriteEngine on
    RewriteBase /
    RewriteRule ^u/(.+)? http://$1 [L]
    

    即:

    如果您发现对 /u/something 的请求,请将其重定向到 http://something

    然后在你的 HTML 中:

    <a href="http://yourdomain.com/u/google.com" target="yourIframeName">Link</a>
    

    我放置了/u/ 部分,因为没有它,您的网站很难让除index.php 之外的其他页面正常工作。我们需要一种方法来区分 普通 URL 和 iframe 重定向

    【讨论】:

      猜你喜欢
      • 2017-06-01
      • 2012-04-15
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 1970-01-01
      • 2020-09-25
      • 1970-01-01
      • 2011-01-18
      相关资源
      最近更新 更多