Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
Zdenek1
New Contributor II

Scripting - URL path replacement

I have this string:

 

when HTTP_REQUEST{
    path = HTTP:path_get()
    
    debug("Path rewrite starts for Path %s ", path)

    -- replace path which is /prefix/something/* so only /something/* stays in the path
    HTTP:path_set("%s", path:gsub("/prefix", ""))

}

 

How to achieve the removal of the prefix? This script does not work. Also I don't see debug messages in the logs even though Scripting logging is enabled.

 

Thanks

3 REPLIES 3
CatInHat
New Contributor III

Try running the regex directly to make sure it removes the prefix correctly. For example, try running the following code in your environment:
local path = "/prefix/something/example"
local modified_path = path:gsub("/prefix", ")
print(modified_path)

Zdenek1
New Contributor II

Hi, I guess missing " in your args for gsub is a typo, right?

Anyway I have added the log using print as you suggested, I still don't see anything in Script logs, but I have "Script Category" enabled in "Local log" settings.

How it is with logging at FortiADC, what else is needed to get the logs visible, do you know? Thanks

Zdenek1
New Contributor II

So after all it is "log" command to log stuff in Script, it is not "debug" nor "print".

Labels
Top Kudoed Authors