0
votes

I've enabled url management within my YII project. Most of the links are working, however i have a few links which have an id which is obtained from the database, these links aren't working.

localhost/project/site/contact <-- This link is working

localhost/project/site/page&view=contentpage&id=1 <-- This one isn't.

How can i get this link to behave as a seo-friendly url?

These are my current rules within the urlmanager in my main.php file.

    'urlManager'=>array(
        'urlFormat'=>'path',
                    'showScriptName'=>false,
                    'caseSensitive'=>false, 
        'rules'=>array(
            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

        ),
             ),   

Thank you so much already!

Edit- I have now changed the url to have a ? instead of a &. The link is now working, but how do I make it seo-friendly, any idea's? Thanks! :)

1
The 2nd one shouldn't work as it cannot determine controller and achtion. The first '&' should be a '?'. Does that solve anything? (localhost/project/site/page?view=contentpage&id=1) - Blizz
try localhost/project/site/page/1?view=contentpage - Developerium
Thank you so much for your replies. The link is indeed working now! Thanks for your replies. However it isn't really seo-friendly, any idea on what rule I should create to make those links seo friendly? - user3240230

1 Answers

0
votes

rule: '<controller:\w+>/<action:\w+>/<id:\d+>/*'=>'<controller>/<action>',

url:localhost/project/site/page/1/view/contentpage