PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 15, 2022

[FIXED] setup route for cakephp3 html url

 March 15, 2022     cakephp, cakephp-3.0     No comments   

Issue

I have URL like article_title_page-c-31-c-2.html

where I want to map to the articles controller and action category, where article_title_page can be any value, the number 31 and 2 will be pass as parameter to the action category, and
-c- and -c- is fixed and is used to show that is should be sent to the article controller and action category, how can I do such a route in cakephp3.5?

I try the below in the route file, but problem, it can't differentiate the -c- or article_title_page-d-31-d-2.html will also go to the same controller and action, which I want to filter out

Router::connect('/:slugc-:id:c-:page.html',
    ['controller'=>'products', 'action'=>'category'],
    ['pass' => array('id','page','slug'), 'id'=>'[\d]+','page'=>'[\d]+'  
    ]
    );

Thank you for any suggestion.


Solution

I haven't tested this locally, but try this:

/:slug:c1:id:c2:page.html

And match c1 and c2 via regex to be c-.



Answered By - floriank
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing