Generating URLs
Yii allows you to not only route your URLs to different controller actions, but also to generate a URL by specifying a proper internal route and its parameters. This is really useful because you can focus on internal routes while developing your application, and only worry about real URLs before going live. Never specify URLs directly and make sure that you use the Yii URL toolset. It will allow you to change URLs without rewriting a lot of application code.
Getting ready
- Create a new application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
- Find your
@app/config/web.php
file and replace the rules array as follows:'urlManager' => array( 'enablePrettyUrl' => true, 'showScriptName' => false, ),
- Configure your application server to use clean URLs. If you are using Apache with
mod_rewrite
andAllowOverride
turned on, then you should add the...