FortiWeb
A FortiWeb can be configured to join a Security Fabric through the root or downstream FortiGate.
AACastillo
Staff
Staff
Article Id 412879
Description This article describes how to add 'www' to the beginning of a URL and configure URL redirection rules in FortiWeb.
Scope FortiWeb.
Solution

There are scenarios where it's wanted to add 'www' to a published URL through FortiWeb, for example, from 'http://anydomainabced.com'  to 'http://www.anydomainabced.com', and then maintain this new domain name with 'www' when other URLs in the same domain name are requested. It is possible to do this using URL redirection rules.


Access to FortiWeb GUI. Then go to Application Delivery -> URL Rewriting, select URL Rewriting Rule, and select Create New:

 

01a.png

 

Configure the following parameters in the New URL Rewriting Rule:

  • Name: Rule name (Write any name, preferably without spaces).
  • Action Type: Request Action.
  • Request Action: Redirect (301 Permanently).
  • Select OK.

 

02a.png

 

In the URL Rewriting Condition Table, the 'Create New' button is now enabled; select this button. In New URL Rewriting Condition, configure the following settings (keeping in mind the example URL is http://anydomainabced.com).

  • Object: HTTP Host.
  • Regular Expression: ^anydomainabced.com$
  • Protocol Filter: Disable.
  • Meet this condition if: Object matches the regular expression and the protocol filter.
  • Select OK.

 

03a.png

 

The URL Rewriting Condition Table will show the recently created HTTP Host object.

 

04a.png


Create a new URL Rewriting condition. In New URL Rewriting Condition, select Create New and configure the following parameters:

  • Object: HTTP URL.
  • Regular Expression: ^/(.*)$
  • Protocol Filter: Disable.
  • Meet this condition if: Object matches the regular expression and the protocol filter.
  • Select OK.

 

05a.png

 

In the URL Rewriting Condition Table, verify the HTTP Host object IS ABOVE the HTTP URL object in the list (those two entries must be in that order).

 

06a.png


Go to the Replacement Location field, and configure:

Location: http://www.anydomainabced.com/$0 (If the URL direction will use HTTPS, change http to https). When it is finished, select OK.

 

07a.png


Configure the created rule in a URL Rewriting Policy. Go to Application Delivery -> URL Rewriting, select URL Rewriting Policy, and select the URL Rewriting policy that will have this rule; if there is any policy or a new policy is needed, create a new one by selecting Create New.

 

08a.png

 

Write a name to the New URL Rewriting Policy and then select OK.

 

09a.png


To configure the URL redirection rule in this policy, select Create New. In New URL Rewriting Item -> Rewriting Rule Name, choose the created URL Rewriting rule, leaving Continue executing the next rule disabled. Then select OK.

 

10a.png

 

Configure this URL redirection policy in the Web Protection Profile used in the respective server policy.

 

Alternative configuration:

Another option to add www to the domain name is enabling Redirect Naked Domain in the server policy; in an HTTP content routing policy, enable this option only if all domains need to be redirected to the naked domain. The Redirect Naked Domain is only available in Reverse Proxy mode.

 

If only an HTTP Content routing policy needs to be added 'www' in the domain name, create a separate web protection profile and apply a URL rewriting rule to it. Then, associate the newly created web protection profile with the content routing policy by disabling the 'Inherit Web Protection Profile' option.

 

Commands to enable redirect-naked-domain:

 

config server-policy policy

    edit <Policy_name>

        set redirect-naked-domain enable

    end

end

 

Commands to disable Inherit Web Protection Profile for content routing policy:

 

config server-policy policy

    edit <Policy_name>

        config http-content-routing-list
            edit 1
                set content-routing-policy-name Redirect_to_naked_domain
                set profile-inherit disable
                set web-protection-profile <newly created web protection profile>
                set is-default no
                set status enable
            next

        end

end

 

Related documents:

Rewriting & Redirecting configuration

Redirect Naked Domain