I'm inside an observer
<event name="layout_load_before">
<observer name="add_robot" instance="FranceTombale\Robot\Observer\NoindexfollowOnProduct" />
</event>
My goal is to alter the layout of some specific url
So inside the observer this is what I have :
use Magento\Framework\App\Response\RedirectInterface;
$redirectUrl = $this->redirect->getRedirectUrl();
$logger->info('Redirect url observer :'.$redirectUrl);
$linkCollection =$this->linkNoIndexCollection->getItems();
foreach ($linkCollection as $item) {
$urlItem = $item->getData('url');
if ($urlItem == $redirectUrl) { // .... the code logic updating the layout }
}
But this is not acting like I would like it act.
For example, if i'm on the page htpp://website/home
and I try to go on the page http://website/myproduct
then the value of $redirectUrl
is htpp://website/home
when what I would need for my logic to work is to get the value http://website/myproduct
Any ideas ?