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