Let's say be navigate through site1.com site2.com/a.html then it redirects to site2.com/b.html automatically. if you press back button on webview in an app, it tries to go back to site2.com/a.html which redirect you to site2.com/b.html which is not desirable. If you try this on chrome browser you go back to site1.com.
How can this achieve programmatically?
You may use this answer's approach https://stackoverflow.com/a/6077173/2879783
And If I didn't got you wrong, you may implement the following: