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

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?

share|improve this question
Be sure that you understand that Custom web addresses do NOT work with SSL. You cannot have If your users are logging in using the portal for authentication they will get redirected to the domain since that's the domain that SF has SSL certs for. – Peter Knolle Oct 12 '12 at 23:39
up vote 2 down vote accepted

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

share|improve this answer

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.

share|improve this answer
Is this still correct as at December 2013? – Steven Herod Dec 2 '13 at 4:51
yes, still not supported – Ryan Guest Dec 2 '13 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 :

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

share|improve this answer
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 Dec 7 '12 at 15:42
Please try the code .It works ! – Mohith Shrivastava Dec 7 '12 at 16:50
It compiles, but if I login with site.login why would I redirect to the Jsp page to login again? – Ryan Guest Dec 7 '12 at 17:28
startURL should be = '/home/home.jsp' or the relative URL of any other tab – Suman Krishna Saha Mar 8 '13 at 7:13

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.