I'm trying to redirect from one pdf file to another. So, for example:
https://my-site.com/the-first-file.pdf
should redirect to
https://my-site.com/the-second-file.pdf
I looked github's documentation on redirects, but I can't add that metadata to a pdf file...
Any help appreciated!
An alternative (and slightly better IMO) way to do this would be to mimic what the jekyll-redirect does, using the meta http-equiv="refresh" tag to ask the browser to redirect the user, which does not require javascript.
i.e. you would delete the the-first-file.pdf and create a file called the-first-file.pdf.html with the following content:
<!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>
Even better, you could take advantage that Jekyll is generating this file, and use site variables to construct the URL based on the configuration settings (which you could also do in your javascript version, of course):
---
---
<!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>
I found a way. Delete the-first-file.pdf and create a file named the-first-file.pdf.html with the contents:
<script type="text/javascript">
document.location = "/the-second-file.pdf"
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With