Permalinks not working

(Carl Moebis) #1

after using the bbpress import script it seems that a bunch of topic title urls were changed, just ever so slightly. I have a redirect json on my ghost site which is hosted on the root domain that does a good job at translating old bbpress topic paths to discourse while forwarding them on to the new domain name too:

"permanent": true,
"from": "^/forums/topic/([a-z0-9\\-]+)",
"to": "$1"

like I said, most stuff comes across. But for some reason some topics, words like “of” “for” “on” “the” “and” and and extra “-” with some S’s in the title. So I thought ok, ghost redirects are getting like 75% of them across, but 25% are dying on the discourse side because of these variations in the URL. So I thought I would use the permalinks function on the discourse site to manually map those:

So the OLD URL:

Should convert to the NEW URL:

…but it never captures the OLD URL. I tried the full URL including the domain name, I tried “/t/” instead of “t/” …the only thing that worked was went I removed the “t/” completely and just used “tony-hsieh-zappos-hiring-culture” but then I it only worked when the URL was entered too without the /t/. Any thoughts?

(Jay Pfaffman) #2

Yeah, the slugs don’t match, so that way won’t work.

See There should be permalinks defined for each topic so that something like /forums/topic/XXX is redirected to the correct topic. If the permalink isn’t what your old site has, you can use the site setting permalink normalizations to insert a regex to fix things up.

Once that’s in place you can shut down the ghost site.

(Carl Moebis) #3

Thanks Jay, but two things.

  1. I can’t shut down the ghost side because it sits on the root domain that the old forums used to: …that is why I’m using the redirect.json to push all old topics to or /t/
  2. The new paths that were converted using the bbpress import script changed some (not all) of the URLs slightly. Looks like it added words like “the” “and” “or” and “-s”.

So what I want to do is hand map those one off cases to correct the URL once it’s pushed to the Discourse side. Only problem is that /admin/customize/permalinks does not work. It doesn’t like remapped /t/NAME-HERE to /t/NAME-IS-HERE.

(Jay Pfaffman) #4

If the permalinks were created by the import script then you can use them and have the ghost site redirect to the permalinks and not have to remap anything by hand.

(Carl Moebis) #5

Already thought of that. For some strange reason the ghost json ignores these one offs because of my blanket expression to cover the other 75%:

	"permanent": true,
    "from": "^/forums/topic/([a-z0-9\\-]+)",
    "to": "$1"
	"permanent": true,
    "from": "^\\/forums(\\/?)$",
    "to": ""
	"permanent": true,
    "from": "^\\/shop(\\/?)$",
    "to": "/join"
	"permanent": true,
    "from": "^\/([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/([a-z0-9\\-]+)",
    "to": "/$4/"

So if I added:

    "permanent": true,
    "from": "^/forums/topic/vikas-oberoi-and-herb-kellehers-love-for-barbells",
    "to": ""

It’s ignored, even if I put it first in the list. That is why I wanted to forward them once more when they make it to the Discourse side using that permalink function, which doesn’t seem to work for /t/ urls.

(Jay Pfaffman) #6

You should be able to have a single forward from /forum on the old site to the discourse site and have it handle all of the redirects. Only this disk site knows both the old url and the new one.

(Carl Moebis) #7

Jay, I’m a little lost, maybe an example to help me understand. You’re saying to have ghost just forward everything to discourse side, leaving /forums/topic/ORIGINAL-NAME intact (just with the new sub domain) and there is something on the Discourse side that will see that old URL and change it to /t/ORIGINAL-NAME-BUT-SLIGHTLY-DIFFERENT?

I think I can figure out how to get Ghost to forward everything, but what do I need to put in on the Discourse permalink side?

(Jay Pfaffman) #8

Did you look at the permalink link above? Did the import script create the permalinks?

(Carl Moebis) #9

no, that is why I’m confused.

(Jay Pfaffman) #10

The interface is bad. Search for a topic id from the old forum. If the import script was run properly you should see permalinks for all topics

(Carl Moebis) #11

Did a search. There is nothing else there. The lone t/tony… that you see was me trying to force these one off to correct, it was missing “of” after hsieh.

If the import script did work the way it was supposed to, then this:

would turn into this:

notice the only things different, apart from the /t/ and 447 is the -s- in the middle.

So assuming the import script behaved badly, and it’s loo late. How do I force these, even if I have to hand enter 20 of them?

(Jay Pfaffman) #12

So there is no permalink matching ‘vikas’? If that’s the case then the permalinks didn’t get created for some reason.

And then what you’d do is just create them yourself in discourse, I think.

(Carl Moebis) #13

That is what I’m trying to do, but it ignores them. See:

should translate to:

…funny enough, if I remove the “t/”, then:

does forward to

but that won’t work, because everything being pushed over is with the /t/

(Jay Pfaffman) #14

If the permalinks are there, as it appears they are, you should be able to fix any mismatch with permalink normalizations.

You can’t really see them in the web interface, so you’d need to look at what’s there in the rails console.


Might be enough for you to see what’s there.

If it’s worth $500 to you I’ll figure it out. My contact info is in my profile.