如何在静态网站上创建重定向?
How do I create redirects on a static website?
我在 GitHub 页上托管了一个 Jekyll 网站。
我想创建指向其他地方的短链接。例如 example.com/l
可以重定向到 linkedin.com/example
.
有没有一种方法可以在静态托管网站上实现此目的而不影响我的域名注册商?
您可以使用添加到页面 <head>
部分的 <meta>
标签。
<meta http-equiv="Refresh" content="0; url='https://your.redirect.here'" />
这将在页面加载时重定向浏览器。
看来您需要在 jekyll 中为 example.com/l
创建一个页面。在该页面上,您可以使用
添加 script
标签
window.location.replace("linkedin.com/example")
到 simulate an HTTP redirect or try 从这个踩。
您可以使用 jekyll-redirect-from
plugin for Jekyll, which allows you to specify that a page should be redirected to a different website.
在您的示例中,您将创建一个名为 l.md
的页面,其前端内容如下所示:
---
title: My LinkedIn Profile
redirect_to: https://linkedin.com/example
---
我在 GitHub 页上托管了一个 Jekyll 网站。
我想创建指向其他地方的短链接。例如 example.com/l
可以重定向到 linkedin.com/example
.
有没有一种方法可以在静态托管网站上实现此目的而不影响我的域名注册商?
您可以使用添加到页面 <head>
部分的 <meta>
标签。
<meta http-equiv="Refresh" content="0; url='https://your.redirect.here'" />
这将在页面加载时重定向浏览器。
看来您需要在 jekyll 中为 example.com/l
创建一个页面。在该页面上,您可以使用
script
标签
window.location.replace("linkedin.com/example")
到 simulate an HTTP redirect or try
您可以使用 jekyll-redirect-from
plugin for Jekyll, which allows you to specify that a page should be redirected to a different website.
在您的示例中,您将创建一个名为 l.md
的页面,其前端内容如下所示:
---
title: My LinkedIn Profile
redirect_to: https://linkedin.com/example
---