Actually I need 2 magento instances of same site. One is something like production site other is like dev site. I make all the changes in the dev site and show to client or some other.
I have set up main site.(http://example.com/magento) copied all the content and placced it in a new directory(http://example.com/magento2) also created a new database and imported the data from main site.
Changed database name
env.php and changed store urls in
core_config tbl in new database.
Now if I go to http://example.com/magento2, its working fine. But When I click the links or products it redirects to main site urls like http://example.com/magento/men.html instead of http://example.com/magento2/men.html
Even the admin login is redirected to main site url.
Any other changes are needed other than changing store url in db and db name in