When I enter my site’s internal URL for example-
xyz.com/women/tops
It redirects me to the home pagexyz.com
and also shows the error in
Google Search Console showingURL is not available to Google
as
shown in the screenshot.
What I want is My Url should be redirected to the current store URL(not base URL) and also not show an error in Google Search Console.
I’m redirecting to a different store following way which is not the correct way to redirect to store Url, Also it’s redirected as expected but shows the error in google search
$storeId = 1;
$urlInterface = MagentoFrameworkAppObjectManager::getInstance()->get('MagentoFrameworkUrlInterface');
$redirecturl = $urlInterface->getCurrentUrl();
$redirecturl = str_replace($this->storeManager->getStore()->getBaseUrl(), '', $redirecturl);
$redirecturl = explode('?', $redirecturl);
$store=$this->storeManager->getStore($storeId);
$observer->getControllerAction()->getResponse()->setRedirect($store->getBaseUrl().redirecturl(0)."?geoipss_redirect=1&gipss_store_id=".$storeId); //redirecturl(0) == 'women/tops'
return $this;
I have tried adding a static URL that works fine in
setRedirect()
but I need to redirect to a specific store’s current URL(not base
URL).I have also tried with
$this->storeManager->getStore()->getCurrentUrl()
it shows error in
google search.
Let me know If anyone has any idea.