Reputation: 519
We have implemented an error handler for Yii 1. Also we have implemented the mail functionality with this as any error occurred an email will be send to us but the problem is we are not getting the current URL on which error is generating. Like one page controller/action can contain many images favicons etc. So if any image is missing then we are getting the image URL which showing 404 from:
$url = Yii::app()->createAbsoluteUrl(Yii::app()->request->url);
But we are not getting current URL not even in $error = Yii::app()->errorHandler->error.
So we are not getting the page in which image is absent. Please let me know if is there any way to get current page URL as I have tried many ways but all they are returning the missing images URL instead of main page URL for which images are missing.
Upvotes: 0
Views: 127
Reputation: 22154
createAbsoluteUrl()
expects route as first argument - it may return random results if you provide URL instead of route (like in your code snippet).
If you want absolute URL of current request, you may use combination of getUrl()
and getHostInfo()
:
$url = Yii::app()->request->getHostInfo() . Yii::app()->request->getUrl();
Upvotes: 1
Reputation: 934
In case of error you can get current page url using Yii::app()->request->requestUri
in Yii 1.
Upvotes: 0