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

Not found page has wrong urls #33

Closed
laziz-karimov opened this issue Jul 1, 2015 · 10 comments
Closed

Not found page has wrong urls #33

laziz-karimov opened this issue Jul 1, 2015 · 10 comments

Comments

@laziz-karimov
Copy link

I have a page with url
something.com/en/controller/method?id=12
and this page does not exist.

Generated links are:
something.com/ru/site/error?id=12
something.com/de/site/error?id=12
something.com/fr/site/error?id=12

But I need
something.com/ru/controller/method?id=12
something.com/de/controller/method?id=12
something.com/fr/controller/method?id=12

Any ideas? Thanks a lot in advance

@laziz-karimov
Copy link
Author

Sorry, I've read closed issues, and found the answer

@laziz-karimov
Copy link
Author

As I understood correctly, this issue was a bug in previous versions? I guess I am missing something, only 404 pages are having wrong language urls...

@laziz-karimov laziz-karimov reopened this Jul 1, 2015
@mikehaertl
Copy link
Collaborator

Could you add some simple example code to reproduce? It should especially show how and where you create the links.

@mikehaertl
Copy link
Collaborator

I think, I see now. You've used the example language selection widget, right? The offending line is probably this:

$route = '/'.Yii::$app->controller->route;

When Yii encouters an error, it runs the configured errorAction internally. This seems to change the current controller's route. I'm not sure yet, how to fix this.

@mikehaertl
Copy link
Collaborator

It's not so easy to solve this in a solid way. When a visitor used an invalid URL that leads to a 404, it could be, that the URL could not be resolved to a valid route. But the current route is required by the language selector, to create a different language URL for the current page.

I think, the only valid workaround is not to show the language dropdown on the error page. I know, that's not perfect, but I can't think of a better solution - at least not a simple one.

@mikehaertl
Copy link
Collaborator

@laziz-karimov I've added error handling to the example. Can you try, if this works for you?

1b308f9

@laziz-karimov
Copy link
Author

Thanks a lot for response. It is working now.

Small mistypes in your edited example:
not $this->_isError = $route === Yii::$app->errroHandler->errorAction;
but $this->_isError = Yii::$app->controller->route === Yii::$app->errorHandler->errorAction;

@mikehaertl
Copy link
Collaborator

Ok, thanks. Fixed the example.

@laziz-karimov
Copy link
Author

Small mistype in Yii::$app->errroHandler->errorAction

@mikehaertl
Copy link
Collaborator

Fixed, thanks.

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