0

I use path-format of yii urls... I want change this url

mypage.com/site/profile/username/name

to

mypage.com/profile/username/name

{site: defaultControler, profile: an Action, username: Argument, name: Argument's value }

how can this done by urlManager in yii?

1 Answer 1

1

This should work for you. Add this rule /profile/* into your config.php in components urlManager part. Params like "username" should be forwarded automatically by Yii.

    'urlManager'=>array(
        'urlFormat'=>'path',
        'showScriptName' => false,
        'rules'=>array(
            '/profile/*' => array('/site/profile/'),
        ),
    ),

Also check your .htaccess and allow Rewrite.

Options +FollowSymlinks
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
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, It's work! I just add '/profile/*' => array('/site/profile/'), in urlManager :)

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.