Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double slashes when redirecting (github page on custom domain) #178

Closed
inconvergent opened this issue Apr 22, 2018 · 7 comments
Closed

double slashes when redirecting (github page on custom domain) #178

inconvergent opened this issue Apr 22, 2018 · 7 comments

Comments

@inconvergent
Copy link

Hi

I've noticed something that i'm unable to explain properly. I'm not sure whether this is an error in my configuration, a difference in setup between my local machine and github pages, or something else. I'm posting it here in the hope that you can point me in the right direction.

First. I've installed the same version of jekyll (3.7.3) and jekyll-redirect-from (0.13.0) as what is listed as current on github: https://pages.github.com/versions/

When I'm using redirect_from on my jekyll page it works as expected locally. but on on the github page there is an extra slash.

As an example.

i redirect like this: redirect_from: /summary/2017/

I don't know it is relevant, but my baseurl is "" (empty string).

When i curl the two different pages i get the following:

  curl -v  'http://localhost:4000/summary/2017/' 
*   Trying ::1...
* connect to ::1 port 4000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4000 (#0)
> GET /summary/2017/ HTTP/1.1
> Host: localhost:4000
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK 
< Etag: 6a06d9-1e5-5adc78be
< Content-Type: text/html; charset=utf-8
< Content-Length: 485
< Last-Modified: Sun, 22 Apr 2018 11:57:50 GMT
< Cache-Control: private, max-age=0, proxy-revalidate, no-store, no-cache, must-revalidate
< Server: WEBrick/1.3.1 (Ruby/2.3.1/2016-04-26)
< Date: Sun, 22 Apr 2018 11:59:25 GMT
< Connection: Keep-Alive
< 
<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>Redirecting&hellip;</title>
  <link rel="canonical" href="http://localhost:4000/2017/summary/">
  <meta http-equiv="refresh" content="0; url=http://localhost:4000/2017/summary/">
  <meta name="robots" content="noindex">
  <h1>Redirecting&hellip;</h1>
  <a href="http://localhost:4000/2017/summary/">Click here if you are not redirected.</a>
  <script>location="http://localhost:4000/2017/summary/"</script>
</html>

And on the github page:

curl -v  'http://inconvergent.net/summary/2017/' 
*   Trying 192.30.252.153...
* Connected to inconvergent.net (192.30.252.153) port 80 (#0)
> GET /summary/2017/ HTTP/1.1
> Host: inconvergent.net
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: GitHub.com
< Date: Sun, 22 Apr 2018 11:59:43 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 497
< Vary: Accept-Encoding
< Last-Modified: Sun, 22 Apr 2018 11:57:08 GMT
< Vary: Accept-Encoding
< Access-Control-Allow-Origin: *
< Expires: Sun, 22 Apr 2018 12:09:43 GMT
< Cache-Control: max-age=600
< Accept-Ranges: bytes
< X-GitHub-Request-Id: 8304:04FC:2328C6A:3000660:5ADC792F
< 
<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>Redirecting&hellip;</title>
  <link rel="canonical" href="http://inconvergent.net//2017/summary/">
  <meta http-equiv="refresh" content="0; url=http://inconvergent.net//2017/summary/">
  <meta name="robots" content="noindex">
  <h1>Redirecting&hellip;</h1>
  <a href="http://inconvergent.net//2017/summary/">Click here if you are not redirected.</a>
  <script>location="http://inconvergent.net//2017/summary/"</script>
</html>

The difference is in the <script> tag, and in the canonical link. As you will see there is a // between my domain and the url path.

Let me know if you need more information.

As mentioned I know this may not be the right place, so let me know if I should be asking somewhere else.

Anders

@DirtyF
Copy link
Member

DirtyF commented Apr 22, 2018

It seems to come from your configuration, I can not reproduce your issue on jekyll's website:

$ http --body https://jekyllrb.com/tutorials/
<!DOCTYPE html>
<html lang="en-US">
  <meta charset="utf-8">
  <title>Redirecting&hellip;</title>
  <link rel="canonical" href="https://jekyllrb.com/tutorials/home/">
  <meta http-equiv="refresh" content="0; url=https://jekyllrb.com/tutorials/home/">
  <meta name="robots" content="noindex">
  <h1>Redirecting&hellip;</h1>
  <a href="https://jekyllrb.com/tutorials/home/">Click here if you are not redirected.</a>
  <script>location="https://jekyllrb.com/tutorials/home/"</script>
</html>

@DirtyF DirtyF added the support label Apr 22, 2018
@inconvergent
Copy link
Author

@DirtyF i'm not sure what i'm looking at in your example. i don't see any // in there except the ones in http://. How did you reproduce it?

@DirtyF
Copy link
Member

DirtyF commented Apr 22, 2018

You' looking at Jekyll's website also using redirects on Github Pages

https://github.com/jekyll/jekyll/blame/master/docs/_tutorials/index.md#L5

@inconvergent
Copy link
Author

@DirtyF but i still don't see the same problem in the example you provided. So I don't understand what you mean. And seeing as my versions and the _config is the same in both my cases I'm still not sure what I can do to change the behaviour.

@inconvergent
Copy link
Author

I found the error. my config was using url: http://inconvergent.net/ (with trailing slash). i removed the slash and now it behaves as expected. (i guess this might break something somewhere else in my case, but i can fix that later.)

@pathawks
Copy link
Member

This seems like something we should proactively work to prevent.

Care to open an issue in the jekyll/jekyll repo?

@inconvergent
Copy link
Author

@pathawks i can do that. just describe this case and the solution? (with a reference to this issue here)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants