Html 我如何重定向特定的 tumblr 页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6288111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 09:01:26  来源:igfitidea点击:

How do i redirect specific tumblr pages?

htmlredirecttumblr

提问by ian calimbahin

I want to redirect "http://iancalimbahin.tumblr.com" to "http://iancalimbahin.tumblr.com/home" every time the page is visited. But when I open other pages such as "/tagged/DigitalArts", "/tagged/photos" and other "/tagged" pages, the page still redirects to "/home". How can I exclude certain pages (/tagged) from being redirected?

每次访问页面时,我都想将“http://iancalimbahin.tumblr.com”重定向到“http://iancalimbahin.tumblr.com/home”。但是当我打开其他页面如“/tagged/DigitalArts”、“/tagged/photos”和其他“/tagged”页面时,页面仍然重定向到“/home”。如何从重定向中排除某些页面(/标记)?

回答by Arvin

Customize your tumblelog and try adding this script:

自定义您的 tumblelog 并尝试添加此脚本:

<script type="text/javascript">
if(location.href == 'http://iancalimbahin.tumblr.com/') location.replace('http://iancalimbahin.tumblr.com/home');;
</script>

Put it right after the <head>tag when you select Custom HTMLunder Theme.

<head>当您在Theme下选择Custom HTML时,将其放在标签之后。

回答by Patartics Milán

Using location.replace(url) is quite a good idea, but you should also add a rel="canonical" tag to your head section to notify search engines you prefer to display /homeinstead the pure subdomain in the search engine result pages.

使用 location.replace(url) 是个好主意,但您还应该在 head 部分添加一个 rel="canonical" 标签,以通知搜索引擎您更喜欢在搜索引擎结果页面中显示/home而不是纯子域。

With this javascript redirection generatortool, you can create fully compatible redirect scripts. This also contains a hack to pass the http referrer under IE. You should also add a html redirection meta tag in a noscript element to redirect javascript disabled browsers too!

使用这个javascript 重定向生成器工具,您可以创建完全兼容的重定向脚本。这也包含在 IE 下传递 http referrer 的 hack。您还应该在 noscript 元素中添加一个 html 重定向元标记来重定向禁用 javascript 的浏览器!