Reputation: 15099
I have set enablePrettyUrl
to true
and showScriptName
to false
in my Yii2 config file. My default controller is called public
.
I also have those 2 rules:
[
'pattern' => '<category_id:\w{6}>/<product_id:\w{6}>/<slug:.*?$>/',
'route' => 'public/product',
'defaults' => [
'seo_url' => ''
]
],
[
'pattern' => 'public/<category_id:\d{6}>/<product_id:\d{6}>/<slug:.*?$>/',
'route' => 'public/product',
'defaults' => [
'seo_url' => ''
]
]
that allow me to access a product in my page with the following URL:
http://example.com/123456/987654/this-is-a-prodduct-example-url
Now, I'd expect this:
Url::to(["/product", "category_id" => 123456, "product_id" => 98765, "slug" => "this-is-a-product-example-url"]);
to form any of those:
/123456/987654/this-is-a-product-example-url
/product/123456/987654/this-is-a-product-example-url
/public/product/123456/987654/this-is-a-product-example-url
but instead I'm getting this:
/product/?category_id=123456&product_id=987654&slug=this-is-a-product-example-url
Why is that and how can I fix it?
Upvotes: 1
Views: 171
Reputation: 5291
Upvotes: 1