0

When i open website with localhost/site_name, url immediately becomes localhost/site_name/default_controller_name.

How can i hide it, so that the url only on that main front page becomes localhost/site_name ?

EDIT this is default controller for front page

public function index() {


    $this->set('list', $this->User->Mobilenetwork->find('list', array(
            'fields' => array('id', 'network')
        )));


    if($this->Auth->user() ) 
    { 
        $this->redirect(array('controller' => 'contacts', 'action' => 'index'));
    }


   if ($this->request->is('post')) 
    {
      //saving data. this is a mess currently, i need to move majority of this code to the model
    }
1
  • What is your default controller now? Is it Pages? And did you add that action to Auth allowed actions? Commented Mar 7, 2014 at 14:37

1 Answer 1

2

Have you adjusted your "routes.php" file to make the root url direct to "localhost/site_name/default_controller_name"? If not, go to the routes file within your Config folder and change:

Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));

(which is the default) to this:

Router::connect('/', array('controller' => 'default_controller_name', 'action' => 'index'));

*not sure what version of CakePHP you're running; the above is for 2.4 (though it may be applicable for earlier versions as well).

Sign up to request clarification or add additional context in comments.

8 Comments

hm i tried that one ( Router::connect('/', array('controller' => 'users', 'action' => 'index')); ) but the outcome is: This webpage has a redirect loop
in my users controller i have: if($this->Auth->user() ) { redirect.. } and if ($this->request->is('post')) { ... }
Do you mean that when you go to "root/mysite" in automatically changes the url to "root/mysite/users"? Also, what version of CakePHP are you on?
which code should i post? I'm running latest Cakephp version
@jackel414 yes, www.site.com becomes www.site.com/users
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.