I have a global search form that submits to search action of a controller:
<?=Html::beginForm(['/feqh/search'], 'get', ['class' => 'navbar-form navbar-left', 'role' => 'search', 'id' => 'searchForm']);?>
<div class="form-group has-feedback Right">
<input id="q" type="text" class="form-control" placeholder="<?=yii::t('app','Search');?>" name="q" value="<?= Html::encode(\Yii::$app->getRequest()->getQueryParam('q',""));?>" />
<i class="form-control-feedback glyphicon glyphicon-search"></i>
</div>
<button type="submit" class="btn btn-default"><?=yii::t('app','Submit');?> <i class="glyphicon glyphicon-ok"></i></button>
</form>
I decided to make pretty URL for search through rules as following:
'search/<q:\w+>' => 'feqh/search',
However, submitting the form always generate the following URL:
example.com/feqh/search?q=anySearchString
However, example.com/search/anySearchString is accessible. Here the problem with submitting using the form.
I tried to change the form action URL:
<?=Html::beginForm(['feqh/search'] i.e removing the initial / but It does not make any difference.
By the way, the following rule is working too:
'search' => 'feqh/search', it makes example.com/search?q=anySearchString. However, the applying of this rule preventexample.com/search/anySearchString`