function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SBgooSBgoo 

Create a redirect mechanism on an entire site with a regex (workaround for missing smart links)

Hello, I am trying to solve the issue of Smart Links not supported in the Community Template.
The best workaround I found is to create a redirect rule at the Site level that does something very simple:

- if a web visitor requires to access:
https://success.mydomain.com/articles/en_US/Documentation/How-to-add-an-Access-point
- the visitor is instead redirected (permanent redirection) to:
https://success.mydomain.com/s/article/How-to-add-an-Access-point

I cannot afford doing this manually (creating one redirect rule) for each article/page.

Basically I'll need something as simple as an expression that replaces:
https://success.mydomain.com/articles/en_US/*
with
https://success.mydomain.com/s/article/*

Which is the simplest way to do it? Is it some sort of redirect regex rule? Or there is a way using an APEX class that does some redirection based on parameters (e.g. the article number and the language code)?

Thanks for any suggestion.
 
pconpcon
Everything that I'm reading seems to show that you cannot use wildcards in the redirect.  If you have less than 1000 total redirects, you could do it programatically and just push the redirects to the metadataAPI [1] (under siteRedirectMappings).  I know it's not as automatic as you want but it might get you there.

[1] https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_sites.htm
SBgooSBgoo
Hello Pcon,

thank you for helping. If I could use wildcards that would be fantastic, but it seemed to me that wildcards are not supported. Is that correct? If they are supported, can you point me to an article/tutorial?

The option of using metadata API might also work. Is there a way to call metadata APIs from an apex trigger/class? Again, if you can point me to any article/tutorial, that would help a lot.

Thanks
SBgooSBgoo
Hello,

we found a solution to have SmartLinks working in Community Templates.
https://success.salesforce.com/0D53000002JJt91