将转发的博主网址屏蔽为自己的域网址
Mask forwarded blogger urls to own domain urls
在 carefully written (thanks a lot) on 之后,现在的问题是如何屏蔽 URL?
我的意思是,一旦 blogspot URL 重定向到 mydomain.com,我想继续显示原始 blogspot URL 而不是 mydomain.com。
在私人回答中,您将页面从 blogspot 重定向到您的域。这会导致 url 被更改。但是如果你想在不改变 url 的情况下显示另一个 url 的内容,可以通过使用 .htaccess
file。
htaccess 文件中的代码应该是这样的:
RewriteCond %{HTTP_HOST} ^DomainA.com
RewriteRule ^(.*) http://DomainB.com/ [P]
Here 您可以找到有关 .htaccess
文件的更多详细信息和信息。
我不知道您是否可以将该文件放在您的博客中。如果您无权将此文件放入您的博客,您可以将它放在您的域名托管服务商上,然后从您的域重定向到您的 blogspot 页面,但如果问我 我建议您重定向并鼓励人们访问您自己的网站 而不是让他们使用博客地址。如果您有自己的网站,则不需要博客。
您可以为此使用以下 JavaScript 代码段 -
<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 (This is the homepage) and here(这是来自其他站点的内部 URL,原始 blogspot URL 上不存在)
在
在私人回答中,您将页面从 blogspot 重定向到您的域。这会导致 url 被更改。但是如果你想在不改变 url 的情况下显示另一个 url 的内容,可以通过使用 .htaccess
file。
htaccess 文件中的代码应该是这样的:
RewriteCond %{HTTP_HOST} ^DomainA.com
RewriteRule ^(.*) http://DomainB.com/ [P]
Here 您可以找到有关 .htaccess
文件的更多详细信息和信息。
我不知道您是否可以将该文件放在您的博客中。如果您无权将此文件放入您的博客,您可以将它放在您的域名托管服务商上,然后从您的域重定向到您的 blogspot 页面,但如果问我 我建议您重定向并鼓励人们访问您自己的网站 而不是让他们使用博客地址。如果您有自己的网站,则不需要博客。
您可以为此使用以下 JavaScript 代码段 -
<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 (This is the homepage) and here(这是来自其他站点的内部 URL,原始 blogspot URL 上不存在)