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?
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.
You can remove the index.php in the frontend URLs performing the following steps in Magento's admin section:
In System -> Configuration -> Web -> Search Engines Optimizations, select YES.
/rootdir/.htaccess and uncomment the line:
In my case the subdirectory Magento is in is called
magento2, so change it to your subdirectory path if it is different.
Magento 2.2: Add below line in .htaccess File
AddHandler application/x-httpd-php70 .php .php5 .php4 .php3
After that enable URL Rewrites from Admin:
- Stores>Configuration> Web
- Expand the Search Engine Optimization section
- Set Use Web Server Rewrites to “Yes.”
- When complete, tap Save Config