2
votes

I am working on site

http://solarsmart.com.pk/

and I have created a controller and action for pages which gets all the pages data from database on the basis of last two values from the following url

http://solarsmart.com.pk/pages/page/about/about-us

I want to remove /pages/page which are controller and action respectively. if I set the route as follows

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

It works but then the problem arises that the admin routing pages also redirect to pages/page I want them to remain as they are right now

1
You need to provide all your routes. Alternatively, all your page names.AD7six
I want this url solarsmart.com.pk/pages/page/about/about-us to be like solarsmart.com.pk/about/about-us but the urls with manager prefix to remain as it is solarsmart.com.pk/manager/posts/add but there can be unknown number of pagesAbdul Sami
If you've only got one page write one specific route. If you have multiple pages - please reread my previous comment and edit the question.AD7six

1 Answers

4
votes

I had the same problem and what I did following I got the url from the Router Class like

$curUrl = Router::url();// returns the current url of the page
$curUrl = explode('/', $curUrl); // exploding on the base of '/'

then I checked that if the url has the required prefix or not which in your case will be like the following

if (!in_array('admin', $curUrl)) {
    Router::connect('/*', array('controller' => 'pages', 'action' => 'page', 'admin' => FALSE));
}