【问题标题】:Mask forwarded blogger urls to own domain urls将转发的博主 url 屏蔽为自己的域 url
【发布时间】:2016-05-08 13:12:12
【问题描述】:

how to redirect any blogspot urls with any extension to the mydomain.com corresponding URL 上仔细编写(非常感谢)Rounin's answer 之后,现在的问题是如何屏蔽 URL? 我的意思是,一旦 blogspot URL 重定向到 mydomain.com,我想继续显示原始 blogspot URL 而不是 mydomain.com。

【问题讨论】:

标签: regex .htaccess redirect blogger url-masking


【解决方案1】:

您可以为此使用以下 JavaScript sn-p -

<script>
    site = "http://example.com"; // The site which you want to mask, don't add ending slash
    iFrame = document.createElement("iframe"); // Creates a iframe via JavaScript
    iFrame.setAttribute("src", site + location.pathname); // Set the source of iFrame
    iFrame.setAttribute("class", "maskingFrame"); // Add class to iFrame
    document.body.appendChild(iFrame); // Append iframe to body of page
</script> 

最简单的 CSS 应该是 -

body {
    overflow:hidden;
}
.maskingFrame, body {
    width:100%;
    height:100%;
    border: none;
}

您可以查看演示 here(这是主页)和 here(这是来自其他站点的内部 URL,原始 blogspot URL 中不存在)

【讨论】:

    【解决方案2】:

    在私人回答中,您将页面从 blogspot 重定向到您的域。这会导致 url 被更改。但是,如果您想显示来自另一个 url 的内容而不更改 url可以通过使用 .htaccess file 来完成。

    htaccess 文件中的代码应该是这样的:

    RewriteCond %{HTTP_HOST} ^DomainA.com
    RewriteRule ^(.*) http://DomainB.com/$1 [P] 
    

    Here 您可以找到有关.htaccess 文件的更多详细信息和信息。

    我不知道您是否可以将该文件放在您的博客中。如果您无权将此文件放入您的博客,您可以将其放在您的域名托管服务商上,然后从您的域名重定向到您的 blogspot 页面,但如果问我 我建议您重定向并鼓励人们访问您自己的网站 而不是让他们使用博客地址。如果您有自己的网站,则不需要博客。

    【讨论】:

    • 如何访问 blogspot htaccess 文件?它在哪里?我应该把这段代码放在 blogspot 的什么位置?
    • @Mpondomise 这是一个可以放在网站任何文件夹中的文件。要放置文件,您至少需要一个 ftp 访问权限。我怀疑你有博客的 ftp 访问权限。因此,您不可能从博客重定向到保留您的博客地址的域。但是如果从域重定向到博客是可能的。
    猜你喜欢
    • 2016-05-06
    • 1970-01-01
    • 2017-10-03
    • 2012-12-10
    • 2018-10-21
    • 1970-01-01
    • 2015-03-26
    • 2019-09-20
    • 2015-02-23
    相关资源
    最近更新 更多