Permalink Wildcards

AI-generated summary

The discussion revolves around setting up permalink wildcards in Discourse. DigitalStartup wants to replace their Wordpress site with Discourse and is looking for a way to capture multiple pages at once using a wildcard permalink instead of setting up individual redirects.

DigitalStartup provided an example scenario where URLs starting with “example-a” would redirect to topic ID 100 and URLs starting with “example-b” would redirect to topic ID 200.

pfaffman suggested checking the “permalink normalizations” site setting, which uses regex to modify incoming URLs before matching permalinks. However, this only works for external links, not internal links.

pfaffman further explained the “permalink normalizations” feature and provided an example of how to use regex to strip query strings from topic routes. Stephen also pointed to the site settings page where the permalink normalizations can be configured.

DigtalStartup requested further clarification on the feature.

Soon, I’ll be replacing my Wordpress site with Discourse. Rather than set up a Permalink (or simple 301 redirect) for each URL individually, can I setup a wildcard to capture multiple pages at once? If not, is there a way I can import this data to speed up the process?

Example scenario:

Old Wordpress URLs Discourse Topic ID
/example-a 100
/example-a/example1.html 100
/example-a/example2.html 100
/example-a/example3.html 100
/example-a/example4.html 100
/example-b 200
/example-b/example1.html 200
/example-b/example2.html 200
/example-b/example3.html 200
/example-b/example4.html 200

Visually:

Therefore any URL starting “example-a” would go to 100 and “example-b” would go to 200

See the permalink normalizations site setting. Note that permalinks work only for links coming in to the site from outside. They will not work for internal links. You’ll need to rewrite those in raw.

Please, can you expand on your answer. I’ve updated the question for clarity.

Did you look at /admin/site_settings/category/all_results?filter=permalink?

Does this explanation of permalink normalizations not help?

So you’d do something like

/(example-*)\?.*/\1

so all of the example[123]* would be removed before it’s matched against the permalinks.