FortiAppSec Cloud
FortiAppSec Cloud delivers unified application security and performance with WAF, bot protection, GSLB, DDoS mitigation, threat analytics, and CDN.
kmak
Staff
Staff
Article Id 423305
Description This article describes the steps to use the FortiAppSec Cloud WAF Rewriting Requests policy rule to redirect the root URL directory to subdirectory.
Scope FortiAppSec Cloud WAF.
Solution

The FortiAppSec Cloud WAF Rewriting Requests module feature can be used to add rewrite/redirect rules to redirect website URL requests.

In the case of a FortiAppSec Cloud WAF application website that requires redirecting from the root directory '/' to a subdirectory '/sub', this can be achieved by adding a rewrite/redirect rule.

 

  1. Example of a website landing page before adding the rewrite rule.
                                                                  
kmak_0-1765855631883.jpeg

 

  1. In the FortiAppSec Cloud WAF portal, navigate to the Rewriting Requests module page. Enable the module in the Add Module page if it is not enabled yet. Create a new rule in the Rewriting Requests module page.
                                                                 
kmak_1-1765855631886.jpeg

 

  1. In the rewriting rule, select and add the rule conditions as follows.

Name: Use an identical name.

Actions: Select 'Rewrite URL'.

Rewrite From: ^/$.

 

This is Regular Expressions syntax; the regex used matches only the root '/' directory.

 

Rewrite to: /subURL-directory.

Insert the destination URL directory to be redirected to.

Protocol Filter: Optional, may leave it in default settings.

 

  1. Save the rule settings, and the Rewriting Requests module page shall have the rule added.
                                                                 
kmak_2-1765855631890.jpeg

 

  1. Test the website browsing to verify the URL redirect. The test can also be done by using the cURL command.
                                                           
kmak_3-1765855631894.jpeg

 

Related document:

Rewriting Requests
Contributors