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.

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments Protection Status
Would love your thoughts, please comment.x