jekyll / jekyll-redirect-from

:twisted_rightwards_arrows: Seamlessly specify multiple redirections URLs for your pages and posts.
MIT License
782 stars 114 forks source link

Howto use in 404.html and forward to page.url on different domain? #182

Closed marbetschar closed 5 years ago

marbetschar commented 6 years ago

Hi!

I'd love to use your plugin to forward requests to another URL, since my blog moved from WordPress to Jekyll: https://blog.marco.betschart.name - and my homepage is a GitHub Pages static site too: https://marco.betschart.name

Now, every path on the homepage which can't be found, should be redirected to the blog:

url: "https://marco.betschart.name/my-awesome-title"
redirectTo: "https://blog.marco.betschart.name/my-awesome-title"`

For this, I created a 404.html page on GitHub Pages:

---
title: Redirecting...
layout: redirect
redirect_to:
  - http://blog.marco.betschart.name
---

And now wanted to create a custom layout for the redirect page according to your docs using a combination of {{ page.redirect.to }} and {{ page.redirect.from }}:

<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>Redirecting...</title>
  <link rel="canonical" href="{{ page.redirect.to }}{{ page.redirect.from }}">
  <script>location="{{ page.redirect.to }}{{ page.redirect.from }}"</script>
  <meta http-equiv="refresh" content="0; url={{ page.redirect.to }}{{ page.redirect.from }}">
  <meta name="robots" content="noindex">
  <h1>Redirecting...</h1>
  <a href="{{ page.redirect.to }}{{ page.redirect.from }}">Click here if you are not redirected.</a>
</html>

Unfortunately this redirects to http://blog.marco.betschart.name/404.html - which is not the expected behaviour. How to preserve the initial page.url the user really wanted to visit in the first place and how to pass this to the redirect template?

jekyllbot commented 5 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

pathawks commented 5 years ago

This is not possible.

DirtyF commented 5 years ago

@marbetschar you might want to take a look at Netlify redirections: https://www.netlify.com/docs/redirects/

jekyllbot commented 5 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.