Breaking News
Home / Web / PHP / PHP Howto / How to setup pretty urls in Yii?

How to setup pretty urls in Yii?

For web applications, the bootstrap file is typically index.php. The same is the case of Yii framework too.

The following snippet can be added to apache.conf or defined in .htaccess depending on your hosting setup. This redirect rule convert the routing patterns into pretty urls.

RewriteEngine on

# prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.)
RedirectMatch 403 /..*$
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

So url like


would become




Advertisment ad adsense adlogger