I am new for cakephp. I am trying to rewrite the url to make it SEO friendly.
I have create module in cakephp3 for cms page.
Page Table – url field would like to use as “about-us”
CREATE TABLE IF NOT EXISTS `pages` (
`id` int(11) NOT NULL,
`title` varchar(100) NOT NULL,
`detail` text NOT NULL,
`url` varchar(225) NOT NULL,
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;
Current URL (working)-
https://example.com/pages/view/8
I want to make this like below.
https://example.com/about-us
Please suggest.
2
Answers
In your cakephp3 folder, there is a file “routes.php” in config.
Open the “routes.php” and use:
in side route::
//in PagesController
browser url:: http://localhost/project-name/yogendra
you can compare title with you DB table and display page dynamically
Hope you fixed the issue. 🙂