hiddenite
(Korsos Akos)
October 21, 2014, 9:09pm
1
Hi,
I would like to have a SEO friendly URL and instead of ?param1=value1¶m2=value2 use the /param1/value1/param2/value2 format.
I have already set the urlManager for this with the proper rules, and it is working fine for every action, except the search.
Settings:
'urlFormat' => 'path',
'showScriptName' => false,
'appendParams'=>true,
Rule
'search/*'=>'site/search',
The problem is, on the search page there is a form with several inputs and whenever I submit the form, the url looks like /search?input1=value1&input2=value2&…
As far as I know, the /* for the additional parameters in the rule only works with the createUrl methods.
I have also set the action parameter of the CActiveForm, but nothing changed:
'id' => 'search-form',
'action' => array('/site/search'),
'method' => 'GET',
Is it possible to have a nice URL with the additional parameters separated by slashes on form submissions?
oligalma
(Marc Oliveras)
October 23, 2014, 2:13am
2
hiddenite:
Hi,
I would like to have a SEO friendly URL and instead of ?param1=value1¶m2=value2 use the /param1/value1/param2/value2 format.
I have already set the urlManager for this with the proper rules, and it is working fine for every action, except the search.
Settings:
'urlFormat' => 'path',
'showScriptName' => false,
'appendParams'=>true,
Rule
'search/*'=>'site/search',
The problem is, on the search page there is a form with several inputs and whenever I submit the form, the url looks like /search?input1=value1&input2=value2&…
As far as I know, the /* for the additional parameters in the rule only works with the createUrl methods.
I have also set the action parameter of the CActiveForm, but nothing changed:
'id' => 'search-form',
'action' => array('/site/search'),
'method' => 'GET',
Is it possible to have a nice URL with the additional parameters separated by slashes on form submissions?
'rules'=>array(
'search/param1/<param1:\w+>/param2/<param2:\w+>'=> 'site/search',
)
hiddenite
(Korsos Akos)
October 26, 2014, 12:39am
3
Thanks for the reply!
However the form has several input fields (10+) and not all are required. Therefore I would have to define rules for every possible input permutations(that would be a lot of rules) . I was hoping something more generic.