1

I'm running my test sites off my local host using MAMP on PHP v5.2.4. Ive made quite a few attempts to take backups of two websites configured in CakePHP v1.2, along with transferring the databases and putting in the correct credentials for the database. How the websites connect to the database is through the database.php file in the app/config folder, putting in the credentials below:

class DATABASE_CONFIG {

    var $default = array(
            'driver' => 'mysqli',
            'persistent' => false,
            'host' => 'localhost',
            'login' => 'user',
            'password' => 'password',
            'database' => 'nameofdatabase',
            'prefix' => '',
    );
}

I had the database configurations put in correctly after inputting the username and password.

On the homepage, it looks like the following: homepage which can't read in CSS and JavaScript files

But, when I click on one of the links, it looks like the normal page, reading in the CSS and JavaScript files out of the webroot folder.

Clicked link with linked CSS and JavaScript working

I tried following @EoinMurphy's answer and writing in the RewriteBase / code on all of the .htaccess files with no luck. Even though I have the wrong version of CakePHP, I still used these instructions on configuring the website because it had clearer instructions then this set of instructions that confused me.

I don't understand why it seems the CSS and JavaScript is being read on all of the internal pages, but not the homepage of the website? The only way I can figure out how to link the CSS and JavaScript files is using the <link src="" ... /> on the file to output the index page content.

The only other earlier issue was the output of the links like (http://...) after the links, but it was simply the following in the CSS that make it output:

a:link:after, a:visited:after {
content:" (" attr(href) ")"; /*the content CSS made it spill out the links*/
font-size:90%;
}
1
  • What does your .htaccess file look like in /App/.htaccess. Cake expects this htaccess file to redirect to webroot. On my mac running mamp, I also have to specify the port parameter in the db config to 8889. Commented Nov 27, 2012 at 20:49

1 Answer 1

1

This is relating to my latest findings with moving CakePHP websites from a live environment to a development environment.

When CakePHP is put into a sub-folder of the webroot, the Apache config, RewriteBase must be used.

So if you've installed WAMP, enabled the MOD_REWRITE extension, and moved the 'live' website into C:\wamp\www\live

Open the .htaccess files in \live.htaccess, \live\app.htaccess, \live\app\webroot.htaccess and add the line 'RewriteBase \live'.

As seen here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase

Just to recap a few things to remember:

  1. Enable mod_rewrite
  2. RewriteBase if in a subfolder
  3. Ensure database base settings are CORRECT.
Sign up to request clarification or add additional context in comments.

3 Comments

I was wondering do I create the MOD_REWRITE rule as the Apache documentation shows, or simply put the ReadWriteBase rule within all the .htaccess files?
Put the RewriteBase rule in all the .htaccess files in the subfolder. Root, App/, App/webroot. Not 100% sure if you need all 3, but thats what i use.
Can you edit your answer and post the script you have in your .htaccess files? Thank you!

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.