Hi, I have developed an entire website in Yii-Framework. I am using Yii Url Rewrite. http://www.example.com/popular http://www.example.com/signup http://www.example.com/wallpaper/108/sexy-babes-1920x1200 etc. My client asked that he wants url look like http://www.example.com/popular/ http://www.example.com/signup/ http://www.example.com/wallpaper/108/sexy-babes-1920x1200/ (added slash in the end) Also he wants that if someone opens http://www.example.com/popular he/she should redirected to http://www.example.com/popular/ http://www.example.com/wallpaper/108/sexy-babes-1920x1200 he/she should redirected to http://www.example.com/wallpaper/108/sexy-babes-1920x1200/ He also wants to add this tag on every page of site: <link rel="canonical" href="http://www.example.com/popular/" /> How to do this? Please help. I have to deliver this project ASAP.
Hi, I ended up with this solution: I placed this code in global controller class constructor(i.e. the class from which all controller classes extend) $slash = substr($this->request->url, -1); $url = $this->request->hostInfo.$this->request->url; if($slash != "/"){ $this->redirect($this->request->url."/",true,301); $url = $this->request->hostInfo.$this->request->url."/"; } Yii::app()->getClientScript()->registerLinkTag("canonical",null,$url);