Skip to content

Emulating the QSA (query string append) using redirect handler #10

@thul

Description

@thul

It took a lot of googling and asking in the IRC channel to get this. Might be handy to add thing to the cookbook / docs.

Most applications will work if your regular expression is ^(.*)$ and the substitution is /index.php?path=$1

But if you have an application that uses urls like "/settings/panel/ssh/?edit=true" you will end up with a rewrite like: "index.php?path=/settings/panel/ssh/?edit=true" which will break and return a 404 due to the double ?

The solution is to use the regular expression: ([^\?])(?:?(.))?
and as substitution: index.php?path=$1&$2

If $2 is empty you'll have a weird trailing & but this shouldn't break anything.

note: Phabricator is one of the applications that uses query strings in their friendly urls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions