开发者

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

开发者 https://www.devze.com 2023-02-15 07:11 出处:网络
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/

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?


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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消