I have created a magento 2 setup and currently accessing the site by punching the whole url like


But I would like it to be


How to achieve the same.

  • You can't have domain.com/[some_path]/ set in Magento as 'Base Url'. After [some_path] you'd like to have /frontName/controller/action/. That's the same to localhost/www.qwerty.com/ Better define virtual hosts in webserver conf. Commented Mar 19, 2017 at 9:32
  • What's your local environment?
    – nuovecode
    Commented Mar 19, 2017 at 9:33
  • Env : centos 6, php 5.6, apache 2.2.15 , mysql 5.6.35 Commented Mar 20, 2017 at 5:21

1 Answer 1


I am waiting for about 2 hours for an answer but as no one posted so am giving my answer. Not sure if it's a proper way to do it or it's a hack but it should work.
Create a folder in htdocs named xyz.com and create an index.php file in it. Open that file and write this code.

$url ='url to to your magento ';
header('Location: '.$url);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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