Skip to main content
Ahmed_Galal
Staff
Staff
Apr 30, 2025 11:05 AM UTC

Technical Tip: How to remove a directory from the URL using URL Rewritting

  • Apr 16, 2026 1:37 PM UTC
  • 0 replies
  • 342 views
  • Translate All
Description This article describes how to remove a certain directory from the URL, which can be helpful while migrating from testing to the production environment or vice versa.
Scope FortiWeb.
Solution

In the following scenario, the FortiWeb administrator has been assigned a task to only remove /prod from the below URL and keep the rest:

 

www.Test.com/prod/XISOAPAdapter/MessageServlet?channel=HR_Cloud:WORKDAY:CC_HR_MasterData_SoapOut 

This can be achieved by using URL Rewriting with the following request action: rewrite HTTP Header & matching condition [HTTP URL: ^/prod/(.*)]


url rewriting.png

 

To configure this in the CLI instead, run the following:

 

config waf url-rewrite url-rewrite-rule
    edit "prod"
        set url-status enable
        set url /$0
            config header-insert
            end
            config response-header-insert
            end
            config header-removal
            end
            config response-header-removal
            end
            config match-condition
                edit 1
                    set object http-url
                    set reg-exp ^/prod/(.*)
                next
            end
        next
    end

 

Result:


In the screenshot below, the connection from the client side where the client is sending an HTTP request is shown on the left:


GET /prod/XISOAPAdapter/MessageServlet?channel=HR_Cloud:WORKDAY:CC_HR_MasterData_SoapOut 

 

And on the right side, FortiWeb has removed /prod and kept the rest of the URL.

url rewriting1.png
Related document:
Rewriting & redirecting

Risk and Resilience in the Age of AI. An OT Thought Leadership Summit for Houston's Critical Infrastructure Leaders. Date: Thursday, December 3, 2026. Time: 8:30 am - 1:30 pm (CT). Location: The Westin Houston, Memorial City | 945 Gessner Road, Houston, TX 77024