Hi Fedetibaldo,
Your suggestion did not work.
[{
“from”:“^\/(?!content/images)(.*)”,
“to”:“/blog/$1/”,
“permanent”:false
}]
redirects to:
Hi Fedetibaldo,
Your suggestion did not work.
[{
“from”:“^\/(?!content/images)(.*)”,
“to”:“/blog/$1/”,
“permanent”:false
}]
redirects to:
Shouldn’t it be this?
[{
“from”:"^\/(?!content\/images|blog)(.*)",
“to”:"/blog/$1/",
“permanent”:false
}]
Sorry you are right.
This works:
[{
“from”:“^/(?!content/images|blog)(.*)”,
“to”:“/blog/$1/”,
“permanent”:false
}]
However, this does NOT work:
[{
“from”:“^/(?!content/images|blog)(.*)”,
“to”:“https://anotherdomain.com/blog/$1/”,
“permanent”:false
}]
Which was the original question i had in this thread!!! The $1 no longer works when a new domain is supplied. This WAS working in ghost 1.0
I need it to redirect to another domain!!! Currently it is incorrectly redirecting to https://anotherdomain.com/blog/$1 with the capturing group NOT working.
This issue has been raised before, and can be tracked on GitHub:
The reality of this is that the redirects feature in Ghost is designed to be used within the context of Ghost, and not for redirecting to specific external sources. The most suitable tool for this would be a redirect rule set at the domain level with something like Cloudflare. Not only would this be easier to manage, but it would be faster as well.
I created a pull request ![]()
Look forward to see the issue getting fixed.
Meanwhile- I have already implemented the redirection in Nginx, and it is working well.
Thanks David, fedetibaldo, and everyone who responded.
Love to see this. Thank you for contributing. Looks like it’s already merged!
Hey, I can’t recall if redirects with query parameters got resolved in Ghost? Does anyone know? cc @vikaspotluri123
Looking to redirect a URL with a query parameter from my Ghost site to somewhere else:
{ "from": "/?ref=value", "to": "https://website.com" }
Would appreciate any direction, thanks!
Dang, that’s frustrating. However thanks a lot for the detailed reply ![]()
Happy to help! If there’s only a few query params you care about, you might be able to do it in your nginx config, or use CloudFlare Workers to script your own logic ![]()
That’s a good route for others, but this is on a Pro instance. I’m almost tempted to do it with a meta tag applied with some JS, but I’m not keen on using client JS to do something the server can do pretty well