php - Cakephp redirection calls root folder -


okay have project folder called myproject

this project contains cake.

now have controller called userscontroller , in example want access action called login.

so when go following site: localhost/myproject/cake/users/login

i following error:

'/myproject/cake/app/webroot/index.php/myproject/cake/users/login' 

as far can see goes webroot , try go root of folder again find right url. have no idea why doing this.

here releveant files:

cake folder

.htaccess

    <ifmodule mod_rewrite.c>    rewriteengine on    rewriterule    ^$ app/webroot/    [l]    rewriterule    (.*) app/webroot/$1 [l] </ifmodule> 

index.php

<?php /**  * requests collector.  *  *  file collects requests if:  *  - no mod_rewrite available or .htaccess files not supported  *  - requires app.baseurl uncommented in app/config/core.php  *  - app/webroot not set document root.  *  * php 5  *  * cakephp(tm) : rapid development framework (http://cakephp.org)  * copyright 2005-2012, cake software foundation, inc. (http://cakefoundation.org)  *  * licensed under mit license  * redistributions of files must retain above copyright notice.  *  * @copyright     copyright 2005-2012, cake software foundation, inc. (http://cakefoundation.org)  * @link          http://cakephp.org cakephp(tm) project  * @since         cakephp(tm) v 0.2.9  * @license       mit license (http://www.opensource.org/licenses/mit-license.php)  */  /**  *  cake's root directory  */ define('app_dir', 'app'); define('ds', directory_separator); define('root', dirname(__file__)); define('webroot_dir', 'webroot'); define('www_root', root . ds . app_dir . ds . webroot_dir . ds);  /**  * needs changed if "cake" directory located  * outside of distributed structure.  * full path directory containing "cake". not add trailing directory separator  */ if (!defined('cake_core_include_path')) {     define('cake_core_include_path', root . ds . 'lib'); }  require app_dir . ds . webroot_dir . ds . 'index.php'; 

app folder:

.htaccess:

<ifmodule mod_rewrite.c> rewriteengine on rewriterule    ^$    webroot/    [l] rewriterule    (.*) webroot/$1    [l] 

index.php:

   <?php /**  * php 5  *  * cakephp(tm) : rapid development framework (http://cakephp.org)  * copyright 2005-2012, cake software foundation, inc. (http://cakefoundation.org)  *  * licensed under mit license  * redistributions of files must retain above copyright notice.  *  * @copyright     copyright 2005-2012, cake software foundation, inc. (http://cakefoundation.org)  * @link          http://cakephp.org cakephp(tm) project  * @package       app  * @since         cakephp(tm) v 0.10.0.1076  * @license       mit license (http://www.opensource.org/licenses/mit-license.php)  */ require 'webroot' . directory_separator . 'index.php'; 

webroot folder:

.htaccess

    <ifmodule mod_rewrite.c>     rewriteengine on     rewritecond %{request_filename} !-d     rewritecond %{request_filename} !-f     rewriterule ^(.*)$ index.php [l,qsa]     rewriterule ^/admin$ index.php/dashboards [qsa] </ifmodule> 

index.php

    <?php /**  * index  *  * front controller handling every request  *  * php 5  *  * cakephp(tm) : rapid development framework (http://cakephp.org)  * copyright 2005-2012, cake software foundation, inc. (http://cakefoundation.org)  *  * licensed under mit license  * redistributions of files must retain above copyright notice.  *  * @copyright     copyright 2005-2012, cake software foundation, inc. (http://cakefoundation.org)  * @link          http://cakephp.org cakephp(tm) project  * @package       app.webroot  * @since         cakephp(tm) v 0.2.9  * @license       mit license (http://www.opensource.org/licenses/mit-license.php)  */ /**  * use ds separate directories in other defines  */ if (!defined('ds')) {     define('ds', directory_separator); } /**  * these defines should edited if have cake installed in  * directory layout other way distributed.  * when using custom settings sure use ds , not add trailing ds.  */  /**  * full path directory holds "app", without trailing ds.  *  */ if (!defined('root')) {     define('root', dirname(dirname(dirname(__file__)))); //    define('root', ds . 'home' . ds . 'me'); } /**  * actual directory name "app".  *  */ if (!defined('app_dir')) {     define('app_dir', basename(dirname(dirname(__file__)))); //    define ('app_dir', 'bloglic-2013'); }  /**  * absolute path "cake" directory, without trailing ds.  *  * un-comment line specify fixed path cakephp.  * should point @ directory containing `cake`.  *  * ease of development cakephp uses php's include_path.  if  * cannot modify include_path set value.  *  * leaving constant undefined result in being defined in cake/bootstrap.php  */     //define('cake_core_include_path', root . ds . 'lib');  /**  * editing below line should not necessary.  * change @ own risk.  *  */ if (!defined('webroot_dir')) {     define('webroot_dir', basename(dirname(__file__))); } if (!defined('www_root')) {     define('www_root', dirname(__file__) . ds); }  // built-in server if (php_sapi_name() == 'cli-server') {     $_server['php_self'] = '/' . basename(__file__); }  if (!defined('cake_core_include_path')) {     if (function_exists('ini_set')) {         ini_set('include_path', root . ds . 'lib' . path_separator . ini_get('include_path'));     }     if (!include ('cake' . ds . 'bootstrap.php')) {         $failed = true;     } } else {     if (!include (cake_core_include_path . ds . 'cake' . ds . 'bootstrap.php')) {         $failed = true;     } } if (!empty($failed)) {     trigger_error("cakephp core not found.  check value of cake_core_include_path in app/webroot/index.php.  should point directory containing " . ds . "cake core directory , " . ds . "vendors root directory.", e_user_error); }  app::uses('dispatcher', 'routing');  $dispatcher = new dispatcher(); $dispatcher->dispatch(new cakerequest(), new cakeresponse()); 

it seems you're not understanding how rewriterules works.

when try access url http://localhost/myproject/cake/users/login rewriterule

<ifmodule mod_rewrite.c>     ...     rewriterule ^(.*)$ index.php [l,qsa]     ... </ifmodule> 

is redirecting right after base url (in case http://localhost) index.php , appending there.

that's why you're getting error. want access site this:

http://localhost/users/login 

in "background" webserver executing url this:

http://localhost/index.php/users/login 

and calling according route.

ps: 'error message' posted not error message , assume error tried explain here.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -