0

Here are the rules I am using for the Url Manager.

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => false,
            'rules' => [
            'post/<arg1>/<arg2>/<arg3>/<arg4>' => 'post/filter',
            'posts' => 'post/index',
            ],
        ],

And my .htaccess

RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php

The rule seems to be working and urls like

post/filter?arg1=9&arg2=0&arg3=d&arg4=3 is getting turned into,

post/9/0/d/3

However, I have a search form like below

 $form = ActiveForm::begin([
        'action' => Url::to(['post/filter']),
        'method' => 'get'

the fields in the form are named arg1,arg2,arg3,arg4. Now whenevr I submit the form the url gets back to the format

post/filter?arg1=9&arg2=0&arg3=d&arg4=3

I am not sure if its got something to do with the rules or the way I am submitting the form (I need submit the form by GET method only). Any help? Thanks.

1

1 Answer 1

-1

Try this rule

'post/filter?<arg1:\w+>=<val1:\d+>&<arg2:\w+>=<val2:\d+><arg3:\w+>=<val3:\d+><arg4:\w+>=<val4:\d+>' => 'post/filter/<val1>/<val2>/<val3>/<val4>'
Sign up to request clarification or add additional context in comments.

1 Comment

its not working 'display/<val1>/<val2>/'=>'search/index?<cid:\d+>=<val1:\d+>&<s:\w+>=<val2:\w+>', 'search/index?<cid:\d+>=<val1:\d+>&<s:\w+>=<val2:\w+>' => 'display/<val1>/<val2>/' both way not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.