I’m struggeling here with UrlManager and pretty Urls.
I assume, that
index.php?r=site/page&view=about
will automatically changed into
site/page/view/about
but its not?
instead that is the result:
site/page?view=about
I’m struggeling here with UrlManager and pretty Urls.
I assume, that
index.php?r=site/page&view=about
will automatically changed into
site/page/view/about
but its not?
instead that is the result:
site/page?view=about
if you are using yii2 basic application then go to config/web.php and see the urlManager component there, uncomment the code so you will the get your required result. means you will get pretty url
I setup UrlManager and mod-rewrite properly I think
The Yii debugger can reveal which rule was applied.
In yii2-app-basic I modified site/index
public function actionIndex($view = 'index')
{
var_dump($view); exit;
return $this->render('index');
}
again: I assumed site/index/view/hello-world
instead of site/index?view=hello-world
the first one thows a 404 NotFoundException
site/index
is working fine
dear, i have explain you the way how to set up pretty url from your configuration file so you have to goto config/web.php and un commment the urlManager component so you will have the pretty urls in your browser when locating them
dear, I did that
Question is may w+ match the hyphen? Go and find out.
site/index/view/index
=> 404
Same scenario is working fine with old Yii1.1 app
(IIRC a module will prepend its rules)
which module? I dont have setup any modules
Just a hint, note the parentheses. But I still think you should check which rule is in effect. Perhaps you can show us the url rules. (somebody else may already know a solution or can try it out. My environment isn’t started.)
I added a rule for just testing:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'normalizer' => [
'class' => 'yii\web\UrlNormalizer'
],
'rules' => [
'site/index/<view>' => 'site/index'
],
],
now, site/index/index
and site/index/hello-world
work fine
but I dont want that rule, and I thought I dont need a rule for the pathInfo
- pattern
ok, for the standard behaviour in 1.1 we need a rule in yii2