54909

How to specify a SEO friendly url like twitter www.twitter.com/ using YII framework

Question:

I am currently using the Yii framework, and I would like to know if anyone has any clue on how to setup a SEO friendly url like www.twitter.com/ automatically in Yii? I know how to do so this manually in the config/main.php but I would like to be able to dynamically generate it. I have been able to do it in Grails as well. In Yii, what I know of is that you need to have another parameter like www.twitter.com/l/, but I do not want that parameter, anyone can share?

Thanks.

Answer1:

Edit the config file main.php with this

'components'=>array( ..... 'urlManager'=>array( 'urlFormat'=>'path', 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ), ....

I think it is generated when you create a webapp with yiic-tool

Answer2:

Are you not able to achieve what you want by using the <a href="http://www.yiiframework.com/doc/guide/topics.url" rel="nofollow">URL Manager</a>? If not, can you post an example of what you have currently and what you'd like it to be?

Recommend

  • Grails 2.1.1 - How to develop a plugin with an AstTransformer?
  • Grails 3 - How to publish to Artifactory
  • How do I import an existing Grails 3 (3.0.12) project in IntelliJ 15
  • C# List of Panels
  • Getting unused unique values on a SQL table
  • Error in installing package: fatal error: stdlib.h: no such file or directory
  • Is there a way to save the selected text and highlight it again once the page is refreshed?
  • Cannot get the UserManager class
  • SetWindowsHookEx does not react on media keys
  • List images(01.png) and descriptions(01.txt) from directory
  • Unable to decode certificate at client new X509Certificate2()
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • How to use an array of arrays with array_map(…) in PHP?
  • Initializer list vs. initialization method
  • Nant, Vault & Windows Integrated Authentication
  • Fetching methods from BroadcastReceiver to update UI
  • How would I use PHP exceptions to define a redirect?
  • output of program is not same as passed argument
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Symfony2: How to get request parameter
  • Upload files with Ajax and Jquery
  • ORA-29908: missing primary invocation for ancillary operator
  • Do I've to free mysql result after storing it?
  • Akka Routing: Reply's send to router ends up as dead letters
  • GridView Sorting works once only
  • Invalid access key error using credentials redeemed from an amazon open id token
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • A cron job substitute?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • json Serialization in asp
  • WPF Applying a trigger on binding failure
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Why joiner is not used after Sequence generator or Update statergy
  • coudnt use logback because of log4j
  • unknown Exception android
  • Checking variable from a different class in C#
  • UserPrincipal.Current returns apppool on IIS
  • Android Heatmap on canvas or ImageView