我試圖從一個pdf文件重定向到另一個。因此,舉例來說:如何使用github頁面從pdf文件重定向?
https://my-site.com/the-first-file.pdf
應該重定向到
https://my-site.com/the-second-file.pdf
我對重定向看着github's documentation,但我不能說元數據添加到PDF文件...
任何幫助表示讚賞!
我試圖從一個pdf文件重定向到另一個。因此,舉例來說:如何使用github頁面從pdf文件重定向?
https://my-site.com/the-first-file.pdf
應該重定向到
https://my-site.com/the-second-file.pdf
我對重定向看着github's documentation,但我不能說元數據添加到PDF文件...
任何幫助表示讚賞!
我找到了一種方法。刪除先file.pdf並創建一個文件名爲先file.pdf.html與內容:
<script type="text/javascript">
document.location = "/the-second-file.pdf"
</script>
的替代(和稍好IMO)的方式來做到這將是模仿什麼jekyll-redirect
確實使用meta http-equiv="refresh"
標籤要求瀏覽器重定向用戶,而不需要JavaScript。
即你會刪除the-first-file.pdf
並創建一個名爲the-first-file.pdf.html
,內容如下文件:
<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting...</title>
<link rel="canonical" href="https://my-site.com/the-second-file.pdf">
<meta http-equiv="refresh" content="0; url=https://my-site.com/the-second-file.pdf">
<h1>Redirecting...</h1>
<a href="https://my-site.com/the-second-file.pdf">Click here if you are not redirected.</a>
<script>location="https://my-site.com/the-second-file.pdf"</script>
更妙的是,你可以利用該傑奇是生成此文件,並使用現場變量構造URL基於配置設置(當然,您也可以在您的javascript版本中執行此操作):
---
---
<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting...</title>
{% assign redirect_url = "/the-second-file.pdf" | prepend: site.baseurl | prepend: site.url %}
<link rel="canonical" href="{{ redirect_url }}">
<meta http-equiv="refresh" content="0; url={{ redirect_url }}">
<h1>Redirecting...</h1>
<a href="{{ redirect_url }}">Click here if you are not redirected.</a>
<script>location="{{ redirect_url }}"</script>