RedEye
RedEye

Reputation: 861

Why does index.ctp render as text and not as html/php?

I tried researching this question on my own for awhile, but can't seem to pinpoint the solution. I'm working through the CakePHP Blog Tutorial, and at this section: http://book.cakephp.org/view/1536/Creating-Post-Views

I create the index.ctp file with the code given by CakePHP. Then, when I open the index.ctp file in Safari, it simply shows the code given by CakePHP. It doesn't not render any HTML, nor does it pull the blog data from the database.

If I switch the extension from .ctp to .php, it renders HTML but it does not pull blog data from the database. My database is connected and has the correct information. I think there is an issue with the .ctp extension? Not sure. Has anyone else run into this kind of issue?

Upvotes: 0

Views: 1476

Answers (3)

jumroo
jumroo

Reputation: 1

Please make sure the AllowOverride is set to All (instead of None) in your sites-available/default file.

Upvotes: 0

tacone
tacone

Reputation: 11441

First, try this url:

http://localhost/posts/index

Second, you may have not mod_rewrite enabled in your development environment. On ubuntu for example you can enable it with like this:

sudo a2enmod rewrite

(EDIT: restart apache afterwards)

Third: Check your .htaccess, you need mod_rewrite to be enabled. Also check the tutorial/cakePHP documentation to find out if you missed any step concerning .htaccess and the Rewrite Rules.

Upvotes: 2

benjamin
benjamin

Reputation: 2185

RedEye,

  1. call it the way like tacone wrote
  2. make sure the file is in the correct path according to the conventions
  3. make sure your server process has correct access rights for the file under concern

Upvotes: 1

Related Questions