Redirect appends slash

Hello,

I am trying to set up a redirect.

At some point in the past my posts where at /post/{slug}. This has changed and they now just live at /slug. Since my blog is pointed to from some sources Id like to set up the correct redirects.

This is my rule to do this.

{"from":"^/post/(.*)/$","to":"/$1","permanent":true}

Unfortunately this results in https://maximilianehlers.com/post/testable_modules/ being rewritten to https://maximilianehlers.com/testable_modules// .

Is there anything I am missing here to not have the second / appended?

Thanks for any help!

This is how I redirect, they work properly:

To homepage:

{
    "permanent": false,
    "from": "^\\/tag/name(\\/?)$",
    "to": "/"
}

To other page:

{
    "permanent": false,
    "from": "^\\/tag/name(\\/?)$",
    "to": "/tag/name1/"
}

Ghost forces all URLs to have a trailing slash:

So your redirects are working as intended, but the url /testable_modules gets redirected to /testable_modules elsewhere

hi @vikaspotluri123,

they almost work as intended. The problem I have is that 2 slashes are appended.

So instead of https://maximilianehlers.com/testable_modules/ I end up with https://maximilianehlers.com/testable_modules//, which can not be found and then shows the 404 page.

Aah, the trailing slashes blended together :man_facepalming:

Can you check the redirects in incognito? Everything seems to be working here :thinking:

C:\>curl -I https://maximilianehlers.com/post/testable_modules/
HTTP/1.1 301 Moved Permanently
Cache-Control: public, max-age=31536000
Content-Length: 51
Content-Type: text/plain; charset=utf-8
Date: Sun, 19 May 2019 17:05:31 GMT
Location: /testable_modules
Vary: Accept, Accept-Encoding
X-Powered-By: Express


C:\>curl -I https://maximilianehlers.com/testable_modules
HTTP/1.1 301 Moved Permanently
Cache-Control: public, max-age=31536000
Content-Length: 52
Content-Type: text/plain; charset=utf-8
Date: Sun, 19 May 2019 17:05:48 GMT
Location: /testable_modules/
Vary: Accept, Accept-Encoding
X-Powered-By: Express


C:\>curl -I https://maximilianehlers.com/testable_modules/
HTTP/1.1 200 OK
Cache-Control: public, max-age=0
Content-Length: 11624
Content-Type: text/html; charset=utf-8
Date: Sun, 19 May 2019 17:06:02 GMT
Etag: W/"2d68-Lsr0d3WtmfA8PC2BlR2iQRfL0/I"
Vary: Accept-Encoding
X-Powered-By: Express```
1 Like

Oh wow! I thought I tried this. :sweat_smile:

Thanks alot for trying this!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.