Magento2 Base URL – How to Remove index.php from getBaseUrl()

base-urlmagento2

I write echo $block->getBaseUrl() in my .phtml template, and show output http://localhost/magento2/index.php/. I want to remove index.php from that output. How can i do that?

Best Answer

URL rewrites will remove index.php from url

How to enable URL rewrites?

1   Stores > Configuration > Web
2   expand the Search Engine Optimization section
3   set Use Web Server Rewrites to “Yes.”
4   When complete, tap Save Config

Hope this will help you.

Related Topic