Admin URL frontname is set to "admin" but on hitting the URL http://www.example.com/admin it redirects to localhost/admin

Working on localhost

web/secure/base_url and web/unsecure/base_url is set to http://localhost/sitename

Using Magento 2.1.8

  • check web/unsecure/base_url and web/secure/base_url path value in data base core_config_data table. – Rk Rathod Dec 10 '19 at 12:31
  • so let me know on which server you working. share your server URL is it localhost or else? then I can tell you exact solution. – sarvesh Dineshkumar Patel Dec 10 '19 at 12:36
  • it is localhost. web/unsecure/base_url and web/secure/base_url path is set to localhost/sitename – Sufyan Khot Dec 10 '19 at 12:42

Check your Baseurl and Baseurl secure  

Change From :-


To :-

Then Run This Command :-

sudo php bin/magento cache:flush

sudo php bin/magento cache:clean
  • Finally this worked. Can you explain why this happens? – Sufyan Khot Dec 10 '19 at 13:16

First change from



second, after doing this remove var/cache folder.

  • did the changes but it is still redirecting to localhost/admin – Sufyan Khot Dec 10 '19 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.