Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect /?page=[id] #20

Open
xini opened this issue May 6, 2015 · 1 comment
Open

redirect /?page=[id] #20

xini opened this issue May 6, 2015 · 1 comment

Comments

@xini
Copy link

xini commented May 6, 2015

I haven't managed get the redirects working where there is only parameters from the root, i.e. /?page-id=xy. Is that possible? If not, any hints to what to change?
Thanks.

@TheBnl
Copy link

TheBnl commented Aug 11, 2016

I encountered the same issue myself. Got it working by adding the following to my Page (or HomePage) init method:

public function init() {
    $requestVars = $this->getRequest()->getVars();
    // In my case i needed to redirect /?id=THE_ID
    if (array_key_exists('id', $requestVars)) {
        $this->httpError(404);
    }

    parent::init();
}

The problem is that, the redirect script starts looking for possible redirects only when faced with an 404 httpError. So if the url looks like this: www.example.com/?id=1 it wil not redirect because it finds the home page, thus nothing happens.

Another problem i faced here was in the setup of the redirects, at first i had set up my table like this;

FromBase, FromQueryString, To
/,        id=1,            /some-other-page/

But it could not find the base / because it apparently looked for /home so by forming the table like so;

FromBase, FromQueryString, To
/home,    id=1,            /some-other-page/

It al worked like a charm.

I don't think this is a solution though, more of a workaround until the issue is fixed. Maybe the query string fields can be checked and when in use the 404 error could be thrown?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants