Use as following-
In routes.php
Router::connect('/contact', array('controller' => 'pages', 'action' =>
'contact'));
or
Router::connect('/contact/*', array('controller' => 'pages', 'action' =>
'contact'));
and generate link as
One way
$this->Html->link( 'Contact', array('controller' => 'contact'));
Other way
<a href="<?php echo $this->Html->url('/contact'); ?>">Contact</a>
On Wed, Nov 7, 2012 at 10:17 PM, Paul Willis <[email protected]> wrote:
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>
--
Chetan Varshney
Ektanjali Softwares Pvt Ltd
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.