Loading

Object prefix at the end of Sites or Community URLs results in 404 error

Veröffentlichungsdatum: Apr 3, 2023
Beschreibung

I'm sure if you've ever used Salesforce you may have seen that the URLs contain 3 character paths, something like: https://mydomainurl.my.salesforce.com/001/o.

The '001' is what's known as a 'three-character' entity prefix, and Salesforce contains a lot of them.

Lösung

Salesforce has a large number of standard, internal, and system 3 character entity prefixes, which are not publicly known and reserved for use, it is suggested to avoid having 3 character paths at the end of your URL because it can cause 404 errors when you try to access those pages.

If you're using a 3 character path and using a URLReWriter, make sure the URL entered has a trailing forward slash.

Common Salesforce Standard Objects that use 3 character paths

  • Contacts: 003
  • Cases: 500
Even your own custom objects are given these 3 character entity prefixes.

Avoiding 3 character paths is important for Salesforce Sites

If you've got a Salesforce Site or a Community, then these 3 character entity prefixes might surprise you.

For example, go to your Salesforce Site or Community URL while logged in as admin and put in the following URL:

<community>.force.com/<CommunityPath>/500

You end up seeing the cases related list.

If you have a URLRewriterClass that you use to have cleaner, more user-friendly URLs. Then these 3 character-entity prefixes cause you issues.

If you have articles on your site, and you want your customers to enter a friendlier looking URL, you have them use this URL:

<force.com url>/blog/articles/<ArticleNumber>

But, the articles aren't in the directory 'blog', and the actual Visualforce page may be at:

<url>/articles/<Article_Category>/<Language>/articles/<Article_Number>.

So the URLReWriter class rewrites the <force.com url>/blog/articles/<ArticleNumber> to go to <url>/articles/<Article_Category>/<Language>/articles/<Article_Number>. However, if the <Article_Number> at the end of the friendly URL is one of these 3 character-entity prefixes previously mentioned then instead of the URLRewriter going to the proper article it will redirect to a 404 error.

Salesforce has a large number of these 3 character prefixes that are reserved and returns a 404 instead of redirecting to the page you've mapped.

The part of the URI that is validated is everything after the final forward slash e.g. '/001'. And for these standard objects and other reserved entities, the URLReWriter class is not invoked. Also, if the URL is not connected to the base path of the site/community then the page is 404 (e.g <site>/<base_path>/001 goes to accounts -if the user has permission- but <site>/<base_path>/TestingArticles/001 will 404 regardless of the rules the UrlReWriter follows).

However, continuing with the above example of articles, let's say the article number in question is 001(same as the standard object Accounts) and you use the URL with a final forward slash AFTER the number '/001/' then the URL rewriter is invoked in this case. So, in order to avoid any confusion for your users, it is best to avoid using 3 character paths at the end of your Lightning Platform Sites and Community URLs.

There are a large number of these 3 character entity prefixes that are reserved by Salesforce, however there are many that are not visible or accessible to customers/users. So in order to avoid confusing 404 errors in your Community or Lightning Platform Site we suggest you pad any potential IDs or paths you wish to be used with extra characters to be greater than 3 characters. That way your users don't hit confusing 404 errors.

Nummer des Knowledge-Artikels

000382940

 
Laden
Salesforce Help | Article