0

I want to refresh a site.com visualforce page on submission of a form, adding an additional query string parameter, but when I try and get the current page url it returns the /apex/controllerName route rather than the name of the page on the public facing site.

private String hostName = ApexPages.currentPage().getHeaders().get('Host');

private String url = ApexPages.currentPage().getURL();

private String thisPageUrl = 'https://' + hostName + '/' + url + '&submitted=true';

return new PageReference(thisPageUrl);

I want this to return in format: http:// myform-org.cs99.force.com/testform?currentId=R4Rl00000009YuV&submitted=true

but currently I get: https:// myform-org.cs99.force.com//apex/mytestFormController?currentId=R4Rl00000009YuV&submitted=true

1

You should be using Site.getBaseUrl() instead of the Host parameter. See the Site class for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.