CakePHP Router::url not working correctly

I'am using CakePHP 2.0 for a small admin section of a website. If the user is logged in correctly, I redirect them to the admins dashboard. I do this as following:

$this->redirect(Router::url(array('controller' => 'admin', 'action' => 'dashboard')));

The redirect is done correct, but for some reason the URL where it redirects to isn't correctly build. The URL is in the following structure (note the double [root] sections in the URL - this is what is wrong):

http://localhost/[root]/[root]/admin/dashboard

Off course their are errors shown because this controller / action doesn't exists. The URL should be off this form:

http://localhost/[root]/admin/dashboard

I can't seem to find what the exact problem is since cakePHP is not my core dessert, is there anyone that can point me in the right direction?

Thanks!


$this->redirect("YOUR URL");

example $this->redirect('/admins/dashboard');

This way you can redirect easily!

Class Cake\Routing\Router, URL filter functions are applied to every array $url provided to Router::url() before For example, http://example.com/posts.rss would yield a file extension of "rss". Routes connected in the scoped collection will have the correct path segment� Routing¶. Routing is a feature that maps URLs to controller actions. It was added to CakePHP to make pretty URLs more configurable and flexible. Using Apache’s mod_rewrite is not required for using routes, but it will make your address bar look much more tidy.


You can use the 'full_base' parameter in Router::url. e.g.

$url = Router::url( array( 
    'controller' => 'posts',
    'action' => 'view',
    'id' => $post[id],

    'full' => true
    ) );

This will give you a full base url. I found this fixed routing problems when I was running CakePHP in a subdirectory of localhost.

Router::url doesn't work correctly with subfolders and extensions on , Router::url doesn't work correctly with subfolders and extensions on base path # 2536 which obviously fails as subfolder.json file does not exist. Actually the CakePHP authentication component is making the request. When using multiple groups on a cache config, clearing was not working properly. Clearing un-used cache configs also failed when the directories did not exist. Fixes cakephp#3930


you can simply right like this

$this->redirect(array('controller' => 'admins', 'action' => 'dashboard'));

Routing problems in authentication plugin � Issue #276 � cakephp , Routing problems in authentication plugin #276. Closed string URLs. You need to use Router::url() to ensure that the base directory is applied. The redirect URL ist generated correctly with the base path of the installation. I might not be getting something here, but why does the Flash component points to an element file, and the element file does not print the message? If it is not a bug or incomplete feature, what is it? I asked about this in cakephp slack, didn't find an answer. I searched google, didn't find a solution.


You can simply right this Router::connect('/', array('controller' => 'users', 'action' => 'index'));

Getting Started - Routing, use Cake\Routing\Router;; echo Router::url(['controller' => 'Articles', 'action' => ' view', 'id' => 15]); If they do, Router will not function correctly. There are CakePHP plugins that are able to generate sitemaps for you. This way your sitemap.xml file will be created dynamically on demand and will always be up to date. Avoid duplicate content Slash or no slash: No slash! As outlined in this article, it is very important to only route to either slash or not slash at the end of your actions


Routing — CakePHP Cookbook v2.x documentation, The incoming URL of /pages/the-example-/-and-proof would result in a single passed You can use the second parameter of Router::connect() to provide any routing this tells CakePHP how to know if the URL is correctly formed or not. This allows the requestAction call to bypass the usage of Router::url which can increase performance. The url based arrays are the same as the ones that HtmlHelper::link uses with one difference - if you are using named or passed parameters, you must put them in a second array and wrap them with the correct key.


Using custom Route classes in CakePHP, New for CakePHP 1.3 is the ability to create and use custom route For the following example we are going to make what looks like a While match() is used for reverse routing array parameters into string urls. Since CakeRoute:: parse() will have already create the slug Don't know if that was correct. Php Mysql Query not working properly. php,mysql. No need to use union as it will give a lots of duplicate data What you want to achieve can be done with simple left join or inner join SELECT m.issue_name ,m.issue_type , m.priority ,m.status,m.description , m.start_date,m.end_date,m.duration, s.name as server_name,p.name as product_name from mod_networkstatus as m LEFT JOIN tblservers as


CakePHP - Routing with parameters not working, CakePHP reverse routing: Html link not showing correct link. Firstly In summary , the Html helper is not reverse routing correctly and instead of URLs like this: Here is my router setup: Router::connect('/', array('controller' => 'pages', 'action'� Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.