Skip to content

How does the redirections work? #483

@piyushgarg

Description

@piyushgarg

I am having a website or link http://domain.com/path1?env=val1&envId=val2 and I want to redirect it clean URL to http://domain.com/path0/path1
rules are working fine but not redirections

{"providers":{"domain.com":{"urlPattern": "^https?:\/\/(?:[a-z0-9-]+\.)?domain\.com","rules": ["env","envId"],"redirections":["^https?:\/\/(?:[a-z0-9-]+\.)?domain\.com\/?path0?\/path1"]}}}

I have looked at the lot of examples in data.minify.json but could not understand, I am trying but this piece of code is not working.

this.getRedirection = function (url) {
            let re = null;

            for (const redirection in enabled_redirections) {
                let result = (url.match(new RegExp(redirection, "i")));

                if (result && result.length > 0 && redirection) {
                    re = (new RegExp(redirection, "i")).exec(url)[1];

                    break;
                }
            }

            return re;
        };

I have also looked at the redirections documentation but it does not have sample.

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