mavimo / sculpin-redirect-bundle

Sculpin Redirect Bundle
6 stars 2 forks source link

Absolute vs relative URLs for the redirection #1

Open gnutix opened 10 years ago

gnutix commented 10 years ago

I'm trying to use this bundle to setup a redirect from / (aka /index.html) to /home/ (aka /home/index.html), as my homepage lies in source/home.md. I've done the following in source/home.md :


---
layout: default
redirect:
    - index.html
    - home.md

---
# My template...

I'm developing the website in local with the following command :

bin/sculpin generate --watch --url=http://localhost/path/to/website/output_dev

The issue is that the file index.html generated looks like this :

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta http-equiv="refresh" content="0;url=/home" />
    </head>
</html>

Therefore, when I access http://localhost/path/to/website/output_dev/, I'm redirected to http://localhost/home.

Is there a way to prepend the redirect destination with site.url variable's content ?

Thanks for your help.

mavimo commented 10 years ago

Hi @gnutix sorry for delay on reply (I miss to see you issue).

You create a redirect.html file on your theme, now you need to alter:

    <meta http-equiv="refresh" content="0;url=/home" />

to

    <meta http-equiv="refresh" content="0;url={{ site.url }}{{ page.destination.url }}" />
gnutix commented 10 years ago
<!DOCTYPE html>
{% spaceless %}
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="0;url={{ site.url|trim('/') ~'/'~ page.destination.url|trim('/') }}" />
</head>
</html>
{% endspaceless %}

That's what I ended up doing. Works, but shouldn't this be in the core?