Friday, January 3, 2014

Re: Routing problem with "/*" url

A few things come to my mind off the top off my head.

You could route your controller-action url's first, to catch the actual links such as /members/users/login (is members a prefix, or do you have a users method with login parameter, or do you have that as a custom route?)

Then providing you did those routes correctly, the bottom route would catch anything that didn't match the earlier ones, hopefully your post slug.

Another idea would be to use a regular expression to match the pattern of a "post-slug", if there are any distinguishing features this would be much more effective. If not I would recommend doing something like this:

/posts/post-slug
/blog/post-slug
/keyword/post-slug (i.e. if I was writing on a health care blog, I would use /health/post-slug. This could produce something like /health/top-10-diet-tips which holds the keyword health as well as the slug.)

It would be easier to avoid issues if you did it this way.

HTH

On 3 January 2014 19:09, gonzela2006 <gonzela2006@gmail.com> wrote:
Hi,

I want my posts url to be like this:
so I added the routing rule on routes.php like this

Router::connect('/*', array('controller' => 'posts', 'action' => 'view'));

It works well but other links give 404 error like this one

Error: The requested address '/members/users/login' was not found on this server.

Please advise

Thanks

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.



--
Kind Regards
 Stephen Speakman

--
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: