1

I'm trying to get the public site's url (ending part of it), to control show/hide some controls according to the location apex page being called.

I tried using below.

ApexPages.currentPage().getUrl() 

But it doesn't show the public URL set in force.com sites, but showing apex/Pagename instead.

Can we get the public force.com site url within controller class. Any help would be great. Thanks.

1 Answer 1

5

For a Salesforce Site, use the Site class. Namely, you can use Site.getBaseRequestUrl() to determine the current URL of the request.

Returns the base URL of the current site for the requested URL. This isn't influenced by the referring page's URL. The returned URL uses the same protocol (HTTP or HTTPS) as the current request. The returned value includes the path prefix and never ends with a / character. If the current request is not a site request, then this method returns an empty string.

0

You must log in to answer this question.

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