A
A
Anton R.2019-10-26 23:58:25
Yii
Anton R., 2019-10-26 23:58:25

Yii how to replace %2F with normal slash in address bar?

In general, I want to get a normal readable address so that without straining you can immediately see what kind of controller and action it is, but the% 2F sign plunges me into melancholy and autumn despondency.
How to turn this: /index.php?r=items%2Fview&id=1
into this: /index.php?r=items/view&id=1
("beautiful" url site.ru/items/1 has already been done, I know how to do it , but for learning I think that it will be useful to see everything as it was originally)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2019-11-15
@kimono

If you do not use enablePrettyUrland look at the method UrlManager::createUrl(), then we will see the process of link formation:

$url = "$baseUrl?{$this->routeParam}=" . urlencode($route);
if (!empty($params) && ($query = http_build_query($params)) !== '') {
  $url .= '&' . $query;
}
return $url . $anchor;

And it will immediately become clear that the replacement of "/" with "%2F" occurs precisely in urlencode.
You can try to inherit from UrlManager and change this method, but then you also need to check the request parsing method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question