Rewriting & redirecting : Example: Full host name/URL translation
 
Example: Full host name/URL translation
Example.com wants to translate its domain name: the external DNS name should be rewritten to the internal DNS name, and vice versa.
When the external DNS name www.example.com appears in the client’s request’s HTTP Host: header, it should be rewritten to www-internal.example.com.
In the server’s response traffic, when the internal DNS name www-internal.example.com appears in the Location: header, or in hyperlinks in the document body, it must be rewritten.
To do this, it creates a set of 3 rewriting rules, one for each of parts that FortiWeb must rewrite.
Table 40: Example request host name rewrite
HTTP Host
Regular Expression in URL match condition
www.example.com
www-internal.example.com
Table 41: Example response location rewrite
HTTP Location
Regular Expression in URL match condition
(.*)www-internal.example.com(.*)
Location
$0www.example.com$1
Table 42: Example response hyperlink rewrite
HTTP Body
Regular Expression in URL match condition
www-internal.example.com
Replacement
www.example.com
See also
Example: Rewriting URLs using regular expressions
Example: Rewriting URLs using variables
Rewriting & redirecting
Regular expression syntax
What are back-references?
Cookbook regular expressions