How to remove index.php from URL in Yii2

To remove the index.php, create a file called .htaccess at the root/web/ of your YII2 site. You can find out more about .htaccess here, but for our purposes here we just want to use it to hide index.php in our URLs. Not every web server is the same, but something along these lines should work for your purposes. Make sure you have mod_rewrite enabled on your server.

.htaccess file :

Now go to config/web.php add edit urlManager configurations under components section.

Now browse your application and you will found clean URL and index.php has been removed from URL in your Yii2 application.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

Arjun
I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.
DMCA.com Protection Status