Forum Discussion

mkyrc's avatar
mkyrc
Icon for Cirrus rankCirrus
Jun 22, 2021

How to replace [HTTP::host] using regex

Hi all, I'd like to replace Host information in HTTP header with regexp because I need read dynamic part of (sub)domain. I need change this (example): (.*).domain.com -> %1.newdomain.com F...
  • mkyrc's avatar
    Jun 23, 2021

    My solution without "regex":

    HTTP::header replace Host [string map -nocase {".domain.com" ".newdomain.com"} [HTTP::host]]

    The level 3 (or 4) subdomain is untouched. This solves my problem.

    I'd like to know solution with regex, because sometimes is helpful string manipulation like this: foo.domain.com -> foo.com (in this case is 'foo' is unknown, therefore is regex helpful).