-1

I have an url like http://demo.examplesite.com/videos/9#part-1

How can i change this to http://demo.examplesite.com/videos

please provide solution for this

  • First of all - do you know what `9#part-1` is for? I suppose `9` is a id for a video. So you can't just delete it. Further I doubt that you know what a SEO friendly URL is. Something like `/videos/a-funny-cat-video-9` could be a SEO friendly url. Since there's such a big lack of knowledge you should first learn the basics. – Jurik Apr 23 '14 at 09:14

1 Answers1

0

In order to change the url structure you must edit the url manager in /protected/config/main.php. Below is an example of the url manager (these settings have been changed).

'urlManager'=>array(
  'urlFormat'=>'path',
  'showScriptName' => false, 
  'rules'=>array(
     // custom rules go first
     'product/<slug:[a-zA-Z0-9-]+>/'=>'product/view',
     // default controller url setup
     '<controller:w+>/<id:d+>'=>'<controller>/view',
     '<controller:w+>/<action:w+>/<id:d+>'=>'<controller>/<action>',
     '<controller:w+>/<action:w+>'=>'<controller>/<action>',
     // defaults to a site page if not above
     '<view:[a-zA-Z0-9-]+>/'=>'site/page',
   ),
 ),

You will need to first understand how to use the url manager in order to craft them to your needs. As @jurik mentions in the comments, 9 likely relates to the video and therefore this url is already pretty friendly.

The code above was taken from this guide. I would recommend you read this in order to advance.

http://www.joshuawinn.com/yii-clean-seo-friendly-urls-for-pages/

The Humble Rat
  • 4,586
  • 6
  • 39
  • 73