Search code examples
regexhttp-redirectcherokee

Regex for Redirection problems (Cherokee Web Server)


I'm having a real problem with this because I just can't get my head around regexes.

I'm using Cherokee Web Server and I'm trying to use a regex to perform a redirection.

I need to get the following url (for example)

/parts/tr/accessories/tyres

to the controller like this

index.php?page=parts&catalogue=tr&category=accessories&subcategory=tyres

can somebody help me please!

Thanks


Solution

  • I am not familiar with Cherokee, but the regex would be:

    ([^/]+)/([^/]+)/([^/]+)/([^/]+)
    

    and replacement pattern would look like:

    index.php?page=$1&catalogue=$2&category=$3&subcategory=$4