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: http://wiki.developerforce.com/page/Authenticating_Users_on_Force.com_Sites

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 = 'https://cs13.salesforce.com/secur/login_portal.jsp?orgId=<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 = '[email protected]';
        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 http://mycompany.test.cs13.force.com/apex/SiteLogin, I want it to be something like http://suport.mycompany.com. How would I do that?

  • 2
    Be sure that you understand that Custom web addresses do NOT work with SSL. You cannot have https://support.mycompany.com. If your users are logging in using the portal for authentication they will get redirected to the secure.force.com domain since that's the domain that SF has SSL certs for. Commented Oct 12, 2012 at 23:39

3 Answers 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


You can use a custom web address. See http://www.salesforce.com/docs/developer/cookbook/Content/sites_using_custom_domain.htm 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.

  • Is this still correct as at December 2013? Commented Dec 2, 2013 at 4:51
  • yes, still not supported
    – Ryan Guest
    Commented Dec 2, 2013 at 4:52
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 : http://threeheadsonapike.wordpress.com/2012/06/07/customized-salesforce-customer-portal/

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 Force.com address. To enable a custom Web address, create a CNAME record to your Force.com 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 Force.com domain name and not the site URL. For example, if you entered mycompany when registering your Force.com domain, the CNAME must be mycompany.force.com, 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

  • 1
    the above code is incorrect. if you're already calling Site.login why would you pass in login_portal.jsp as the startUrl?
    – Ryan Guest
    Commented Dec 7, 2012 at 15:42
  • Please try the code .It works ! Commented Dec 7, 2012 at 16:50
  • 1
    It compiles, but if I login with site.login why would I redirect to the Jsp page to login again?
    – Ryan Guest
    Commented Dec 7, 2012 at 17:28
  • startURL should be = '/home/home.jsp' or the relative URL of any other tab Commented Mar 8, 2013 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .