S
S
suzyry2016-01-24 11:05:37
Yii
suzyry, 2016-01-24 11:05:37

How to organize rules in urlManager?

Good day!
I wrote the following in the rules:

'rules' => [
    'post/' => 'post/index/',
    '' => 'main/index',
],

The post controller itself looks like this:
class PostController extends Controller
{
    public function actionIndex($id)
    {
         //получаем запись, где 'id' = '$id'
    }
}

As a result, everything is executed only when you use an address like "site.ru/post?id=12312".
Question: How can I use rules to make a publication available at an address without a GET request, i.e. something like "site.ru/post/12312"? That is, so that the id parameter is passed to action without GET requests.
I beg you to help me with this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-01-25
@suzyry

'post/<id:\d+>' => 'post/index',
Dock by URL Rules .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question