GEOIP redirection causes 404 on specific cases
victoradobe opened this issue · comments
The GeoIP redirect functionality redirects customers to a specific store based on his Geolocation. The problem is that sometimes, the customer is redirected to a page that doesn't exist if the url contains the "store_code" but doesn't have a "/" in the end.
Pre-requisites to reproduce:
- Clean Magento instance with at least 2 store views
1.1 Example: I'm using 2 store views (en and fr)
- Configure store to add store codes to the url (Stores -> Configuration -> General -> Web -> Url Options -> Add Store Code to URLS):
- Configure Fastly (Stores -> Configuration -> Advanced -> System -> Full Page Cache -> Caching Application):
- Configure GeoIP redirect (Stores -> Configuration -> Advanced -> System -> Full Page Cache -> Caching Application -> Fastly Configuration -> Advanced Configuration -> GeoIP Country Mapping):
Steps to reproduce:
- On a incognito tab, access the store front using a code that is not from your geolocation
1.1 Ex: You're from EN, access the other storeview https://store-test.com/fr/ - You'll see the dialog to tell about the redirection
- Now, close all incognito tabs and open a new one
3.1 Access the other storeview again, but now remove the last "/": https://store-test.com/fr
Expected Results
Customer is redirected to the other storeview and sees the homepage
Actual results
Customer will be redirected to the other store but the url will be something like:
https://store-test.com/en/en instead of just https://store-test.com/en/ (notice the extra "en" code)
Additional info
It seems that the error originates on Fastly\Cdn\Block\GeoIp class:
Maybe a check could be done to add an extra "/" to end of the url if there isn't one, or remove all paths completely.