how to change URLs in cakephp through .htaccess
I am using cakephp 1.3 and I wan开发者_如何学运维t the user not to see the traditional cake php urls like:
sitename.com/users/contact, instead I want to use .htaccess to mod_rewrite and generate nice URLs like: sitename.com/contact.
How can I do this using cake phps .htaccess.
Using .htaccess rewrite rules would be quite pointless, since Cake would still generate all links "the Cake way", being completely oblivious to any rewritten URLs.
Instead, use Routes to configure special URLs for certain actions. These will be reverse-routable, meaning anywhere you tell Cake to make a link for array('controller' => 'foo', 'action' => 'bar')
, it will use the configured short route. Example:
Router::connect('/foo', array('controller' => 'foo', 'action' => 'bar'));
echo $html->link('FooBar', array('controller' => 'foo', 'action' => 'bar'));
// <a href="/foo">FooBar</a>
精彩评论