Wednesday, November 7, 2012

Routing

Hi

I'm on CakePHP 2.2.x and I've built all my site links in the format...

$this->Html->link( 'Contact', array('controller' => 'pages', 'action' => 'contact'));

…which generates URLs like http://www.example.com/pages/contact and everything works. ie: /pages/contact shows my contact page.

I've then added the line…

Router::connect('/*', array('controller' => 'pages', 'action' => 'display'));

…as the last rule in my routes file and so now I can use a URL like http://www.example.com/contact (without the /pages bit) and still get my contact page. All great so far.

What I would like to do now is somehow set my links to generate the shortened URLs so $this->Html->link( 'Contact', array('controller' => 'pages', 'action' => 'contact')); generates a URL http://www.example.com/contact rather than http://www.example.com/pages/contact

Is this possible? I'm struggling to find a way to do it. If it is can someone point me to an example?

Regards

PW

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate