问题描述
我使用CakePHP 1.3,我希望用户不希望看到传统的蛋糕PHP的网址,如:
I am using cakephp 1.3 and I want the user not to see the traditional cake php urls like:
sitename.com/users/contact,而不是我想用的.htaccess mod_rewrite的,并产生很好的网址,如:。sitename.com/contact
sitename.com/users/contact, instead I want to use .htaccess to mod_rewrite and generate nice URLs like: sitename.com/contact.
我怎样才能做到这一点使用的蛋糕PHPS的.htaccess。
How can I do this using cake phps .htaccess.
推荐答案
使用的.htaccess重写规则将是毫无意义的,因为蛋糕仍然会生成所有环节的蛋糕路,是完全无视任何重写的URL。
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.
相反,使用路线来配置特殊的URL某些操作。这将是反向路由的,这意味着在任何地方你告诉蛋糕做一个链接,阵列('控制'=>'富','行动'=>'巴')
,它将使用配置短路线。例如:
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>
这篇关于如何通过的.htaccess更改网址CakePHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!