i have created VF page and shown that page in home components sidebar. Now my requirement is to show the browser current URL address on Sidebar component VF page.

Now its showing current VF page URL like: https://c.ap1.visual.force.com/apex/geturl?core.apexpages.devmode.url=1

But i want to the browser current address in VF Page like : https://ap1.salesforce.com/001/o

Any one please help me to over come this problem.

2 Answers 2


If your page is using a controller or extension (if it's not, just create an extension) then you should be able to get the URL you're after using the referer header for the Visualforce page.

Use the following method to get the URL:

public String getReferer()
    return ApexPages.currentPage().getHeaders().get('referer');

Then you can just get this in your page using:

<apex:outputText value="{!Referer}"/>
  • If this is the HTTP referer header will it be the current page that the user is on or the previous page that they navigated here from? From the PageReference Docs - "The URL that is either included or linked to the current request's URL. This header is optional." I might be missing something with how the sidebar works. Nov 22, 2012 at 19:17
  • 1
    @DanielBallinger When you put VF in the side bar you do so via an iFrame, and so the referer is the parent URL which is the one sought after here.
    – Matt Lacey
    Nov 24, 2012 at 3:43

If you're using a Controller, you can use the System.URL class to grab the base URL

Public String baseURL =   URL.getSalesforceBaseUrl().toExternalForm();

You can then bind apex:outputText to this controller variable.

  • Dear techtrekker, Thanks for your replay, I tried your solution. But still I am getting the same problem. I am showing controller code and snap shot of my issue. public string BrowserURL = System.URL.getSalesforceBaseUrl().toExternalForm(); public string getgraburl() { return BrowserURL; } can you please suggest me how can i achieve this problem. thanks mylife....
    – mylife525
    Nov 22, 2012 at 10:15
  • You can use the String replace function to get rid of the 'c.' and 'visual.force.' And you should get the Base URL. I reckon that is because Visualforce is served up from a different subdomain Nov 22, 2012 at 10:38

You must log in to answer this question.

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