Chapter 3. Making Pretty URLs

This chapter explains how to configure URL rules and make URLs pretty, in particular for search engines. We will cover the following topics in this chapter:

  • Using Pretty URLs
  • Custom URL rules
    • Example – news items list by year or category
  • The default parameters in rules
    • Example – the index page to display list links
  • Complete URL rule parameters
  • The URL pattern to support a multilanguage view
  • Creating the rule class

Using pretty URLs

The URL format is very important for SEO. People do not pay attention to URLs (some browsers does not display them at all), but search engines make correspondences between text in the page and the URL.

Until now, we have used this type of URL index.php?r=site/index or index.php?r=site/about, where ...

Get Yii2 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.