sam
sam

Reputation: 698

Putting a php file in cake php

I have a cake PHP project in which I need to put a php file in root folder like 'faq.php' and link it somewhere in the project. But as soon as I point to the url it redirects me to the index page. I don't want to dig deeper just want to add an static link. Here is my .htaccess

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteRule    ^$ app/webroot/    [L]
 RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

Upvotes: 0

Views: 113

Answers (3)

Noneleft
Noneleft

Reputation: 1

You can put any php and call it from wherever you want.

In your Templates Dir you will have an Element Dir - in there create a FAQ dir and in the FAQ dir create a file called faq.ctp.

Then in the faq.ctp just drop in your php code, same as you would if writing in raw.

To call you can just call the element from whichever model you are in like so:

<?= $this->Element('FAQ/faq') ?>

Upvotes: 0

drmonkeyninja
drmonkeyninja

Reputation: 8540

If you want to add any non-Cake content that needs to be accessed via the web browser in CakePHP you need to put it in the webroot folder as Cake's htaccess setup rewrites all other URLs. (If you're using the older CakePHP 2 the webroot folder is in app).

Upvotes: 1

Dakota
Dakota

Reputation: 458

You need to put it in the app/webroot directory.

Upvotes: 1

Related Questions