Normal Behavior
A user expects to return the last viewed page after successful login. This is normal behavior of SAP Commerce Hybris. If a user wants to log in while visiting a PDP (Product Detail Page) or category page, he has to be redirected to the same page after login.
If this functionality is not working as expected, you can do the following fix. Users were redirected to the homepage after login before applying the fix.
Hybris login redirection issue fix
- Open file spring-security-config.xml.
- Find request matcher part
Search for excludeRedirectUrlRequestMatcher
in the xml.
- Find
excludeUrlSet
property in the file
If the list is like the below, it causes an issue.
<property name="excludeUrlSet"> <set> <value>/guest/*</value> <value>/orderConfirmation/*</value> <value>/login</value> <value>/login/checkout</value> </set> </property>
- Change the list by fixing URLs.
Change URLs in the list as below
<property name="excludeUrlSet"> <set> <value>.*/guest/.*</value> <value>.*/orderConfirmation/.*</value> <value>.*/login</value> <value>.*/login/checkout</value> </set> </property>
You may also see official documentation about redirection after authentication.