I am developing a web page using Yii framework, I want to do url management like facebook.
This is my url http://www.mywebpage.com/user/profile/id/10 but i dont want to show this url like this, i would like to show like this http://www.mywebpage.com/yogi can i do it in Yii? please anyone help me.
I am developing a web page using Yii framework, I want to do url
Share
Check this article out to get started:
http://yiitutorials.net/easy/easy-url-rewriting-with-yii
You will bascially be storing the users custom URL in the database. So an example URL would be http://example.com/user/userurl
In your main config you could set up a rule like:
That rule defines that a URL with ‘http://example.com/user/’, the part after the slash can be accessed by a GET variable with the name ‘customurl’. You can then access the users custom URL like so:
And query the user record something like so:
As mentioned below, here is an example from a real website. In this example the URL looks like so: http://website.com/blog/{post_title}/{post_id}
So the rule for this would be something like:
So in our blog controller, we have an action called viewpost (see above how the rule is pointing to this controller/action?), which would look something like:
So any URL that has the format london-blog/some_value/some_value will point to the controller action as specified in the config. You can then access the some_value parts using the variable names defined in the config (the bits in the < :.+>)
Hope that helps!