Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know the rules by which subdomain prefixes are added to org servers.

Both for standard org names (e.g.,, and site org names(,

Is there any way of forcing a single domain for access without any mangling? Are there any good rules for coding to account for the apparent random mangling / redirection that can occur?

share|improve this question

The naming rules are consistent, but you shouldn't concern yourself with the rules. There's only three things you should know for most usual cases.

Most of the sub domains focus on either browser pipelining, such as separating content from code, or isolating modules, increasing security by using the browser's CORS (Cross Origin Resource Sharing).

Rule 1: Url.getSalesforceBaseUrl().toExternalForm() will always give you the current host name. Use this if you need to link back to wherever you are in the current context.

Rule 2: Use Page.pageName to reference a Visualforce page in Apex Code. The system will automagically get you where you intended to go. Also see StandardController and related classes for links to standard pages.

Rule 3: Use URLFOR in Visualforce syntax to automagically link to the right host name. You can link pretty much anywhere with URLFOR, including pages like Log a Call or edit pages.

Bonus: The system is pretty smart, and can usually figure out which host name you should be on, so don't try to outsmart the system unless it really is not working as expected based on the above rules.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.