Just a quick help with redirect json syntax and somehow this is elluding me (the variables part, as I am not a developer):
I want to redirect from my former blog all articles from: domain.com/category/article
to the new Ghost format of domain.com/article
I’ve tried this:
{
“permanent”: true,
“from”: “^([A-Za-z0-9\-]+)(\/?)$”,
“to”: “/$1/”
}
But it is not working…
Later edit: made it to work, but again manually:
{
“permanent”: true,
“from”: “^others/([A-Za-z0-9\-]+)”,
“to”: “/$1/”
},
As if I were to replace “others” with .* it would go into a redirect loop.
But then…
{
“permanent”: true,
“from”: “^personal/([A-Za-z0-9\-]+)”,
“to”: “/$1/”
},
doesn’t seem to work (:boggled:) as it seems only the first rule in the list works and none of the following ones.
Later edit: adding a / (i.e. ^/personal) seems to have solved the issue.
I’ve done the categories manually, i.e. from domain.com/category
to domain.com/tag/category
but this could have been done with a simple regex as well.
{
“permanent”: true,
“from”: “^\/category/technology(\/?)$”,
“to”: “/tag/technology/”
},
(this works)
The examples in the docs (https://docs.ghost.org/v1/docs/redirects) don’t help much as they don’t give the actual result of the redirect. It would help to add in the long list of examples also what they actually do.
For example:
{
“from”: “^/post/[0-9]+/([a-z0-9\-]+)”,
“to”: “/$1/”
},
Redirects from /post/post-name to /post-name/.
Replying to myself with the actual working redirects maybe it helps other people as well:
If you migrated your blog from WordPress to Ghost and wanted to fix the URL’s (assuming your WP permalinks were domain.com/category/), then you need to do the following:
If you want to redirect the category URL’s (i.e. domain.com/category/category-name/) if they were somehow indexed by Google, you need to do the following:
Hey @dsecareanu I take it you managed to get this figured out
Not sure if you have seen this, but our docs (which for sure need an overhaul) have a “suggest edits” button. If you’d like, you can submit suggestions for what information you think is missing from the page.
It’s a hard thing to document cos it depends on how well people know regex, but there’s really not any other way to do redirects!
@Hannah, I’ve submitted some edits , but since I’m not sure what some of the examples describe I’ve left them under “other examples” category. I also tried to restructure de page content a little bit to make it more logical in terms of how it flows and to provide some little extra bits of info that I had to figure out on my own (not being familiar with .json file formats).