How to make clean URLs in Yii2 framework using .htaccess?How to make clean URLs in Yii2 framework using .htaccess?

Hi there,

I’ve website hosted in asphostportal and I am trying make clean url for my website developed using Yii2 framework using .htaccess only. I know that i can use urlmanager class of Yii2. But due to some specific reasons I can’t use it and wanted make clean url using .htaccess only.

I wanted to convert the following url: Url = localhost:8090/index.php?r=site%2Fcontact’ To Url = ‘localhost:8090/contact’

Thanks in advance.

Actually, you have to use both urlmanager and htaccess (if you’re using apache) to have clean url

If you really can’t use UrlManager, you can rewrite your URL’s in your .htaccess file to the actual request for Yii. But you also have to create all URLs within your application manually, as Yii cannot figure out what would be the correct URL. As such, you’re really missing a lot of useful features from Yii.

Why is UrlManager not usable in your case?