zeflex
zeflex

Reputation: 1527

CakePhp Errors (set 404 page)

When I go to http://www.xxxy.com/wp-login.php without a slash at the end, I have the 404 not found page. When I add a slash (http://www.xxxy.com/wp-login.php/), the website appears and is totally broken.

In my AppController I have this:

public function beforeFilter() {
    $this->_setErrorLayout();
    parent::beforeFilter();
}

public function _setErrorLayout() {
    if ($this->name == 'CakeError') {
        $this->layout = 'error';
    }
}

Do you know what is wrong when we have an extra slash ?

Upvotes: 0

Views: 220

Answers (1)

ndm
ndm

Reputation: 60453

Look at the HTML source, you're using relative paths for all your assets.

<link href="css/media.css" rel="stylesheet" type="text/css">
<img src="images/logo.png" alt=""/>

Adding a trailing slash makes wp-login.php appear to be a folder, and consequently css/media.css becomes /wp-login.php/css/media.css, which of course doesn't exist.

You should use absolute paths like /css/media.css, which btw. is what the CakePHP HTML helpers normally generate automatically when used properly.

See also http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html

ps. it's a good idea to allow only either the slashed, or the unslashed version, but that's a different subject.

Upvotes: 1

Related Questions