Find your content:

Search form

You are here

How do I use a custom URL for the Customer Portal


I am trying to have my Customer Portal use a custom URL instead of the Salesforce one. The Salesforce one right now looks like this:

I followed the instructions here to set everything up:

My SiteLoginController looks like this:

global with sharing class SiteLoginController {
    global String username {get; set;}
    global String password {get; set;}

    global PageReference login() {
        String startUrl = '<orgId>&portalId=<portalId>';
        return Site.login(username, password, startUrl);

    global SiteLoginController () {}

    @IsTest(SeeAllData=true) global static void testSiteLoginController () {
        // Instantiate a new controller with all parameters in the page
        SiteLoginController controller = new SiteLoginController ();
        controller.username = '';
        controller.password = '123456'; 


However, when I go to my login page and try and login, nothing happens. How do I get this to work?

Additionally, instead of my portal being at, I want it to be something like How would I do that?

Attribution to: Di Zou

Possible Suggestion/Solution #1

public PageReference login() {
String startUrl =    System.currentPageReference().getParameters().get('startURL');
return Site.login(username, password, startUrl);

Have a look at this section carefully and compare with your code please

Another source code and its working .You may like to try that

global PageReference login() {

  //static org-id and portal id
  String strOrgID = '';
  String strPortalID = '';
  String strURL = '';
  //start url of the page
  String startUrl = strUrl + '/secur/login_portal.jsp?orgId=' + strOrgID + '&portalId=' + strPortalID;

startUrl += '&un=' + username;
    startUrl += '&pw='+ password;

    //set reference and attempt login
    PageReference portalPage = new PageReference(startUrl);
    PageReference p = Site.login(username, password, startUrl);

    //if p==null, no login
    if (p == null) {
          return Site.login(username, password, null);
    } else {
          return portalPage;

This blog might help :

For your second question have a look at this website

Now you have company name .All you need to do is purchase the domain name and map in site settings to work

Custom Web Address The optional branded custom Web address that you registered with a third-party domain name registrar. The custom Web address acts as an alias to your address. To enable a custom Web address, create a CNAME record to your domain with that registrar. If you have not registered this address, you encounter an error. Custom Web addresses aren't supported for sandbox or Developer Edition organizations.Note If you choose to create a branded top-level domain or subdomain through a domain name registrar, the CNAME record that you provide to that registrar must be your domain name and not the site URL. For example, if you entered mycompany when registering your domain, the CNAME must be, not the full value of the site URL.

You will have a field in site settings to specify Custom web address .Need to put your company URL there.This feature avaialable in Production instance only

Attribution to: Mohith Shrivastava

Possible Suggestion/Solution #2

You can use a custom web address. See for more info on setting that up.

Also, it is important to know that in your example above, you are using a sandbox instance (cs13). Custom web addresses are not supported on these instances. If you want to use a custom web address, you will need to use a production instance.

Attribution to: Ryan Guest

Possible Suggestion/Solution #3

Starturl should not be the full URL. /apex/pagename is what you need. For the default portal home page, you can use /home/home.jsp

Attribution to: Shane McLaughlin
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content