I have Sitecore 8.2 update 5 site deployed in Azure PaaS as an App Service. I have created a custom domain (e.g. abc.com) in the App Service. This custom domain is kept behind F5 firewall. I am facing the problem with the item URLs, linkManager.GetItemUrl method is returning URL with App Service URL ( e.g. https://appservicename.azurewebsites.net/pagename) and not with the custom domain.

Please let me know how can i get the correct URL with custom domain name i.e. https://abc.com/pagename.

Thanks, Alok...

  • Which hostname is defined in the site definition? Can you share the site definition?
    – Gatogordo
    Jun 16, 2020 at 21:04
  • App service url is set to the targetHostName attribute in Site Definition. This is working fine if I am keeping the site behind Azure WAF firewall. Network wants to move it behind the F5 firewall.
    – Alok Kumar
    Jun 18, 2020 at 10:06

2 Answers 2


This is probably similar to this question: Incorrect URLs when behind proxy

If you're terminating your request at the F5 and allowing the F5 to make the request directly to the *.azurewebsites.net URL, Sitecore is going to resolve the site with the *.azurewebsites.net URL and subsequently any links generated will be with that hostname. To remedy this, you'll need to use rewrite rules to rewrite the host header with the value of the header of the original request forwarded by the F5 which I believe is the X-FORWARDED-FOR header. There are a few quirks to rewriting the headers on an App Service and you can find more details about it from the below post. Even though this post covers Azure Application Gateway instead of an F5, the concept is the same and you'll need to perform similar steps to rewrite the host header.



You should set the custom domain as targetHostName if you want that in the urls.

The targetHostName is the host name to use when generating URLs to items within this site from the context of another site. If the targetHostName attribute is absent, Sitecore uses the value of the hostName attribute instead. Used only when the value of the Rendering.SiteResolving setting is true.


It could be that your firewall is not sending the original domain - you could change that or fix it with the targethostname property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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