简体   繁体   English

将PHP文件放入蛋糕php

[英]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. 我有一个蛋糕PHP项目,需要在其中将php文件放在“ faq.php”之类的根文件夹中,并将其链接到项目中的某个位置。 But as soon as I point to the url it redirects me to the index page. 但是,一旦我指向url,它就会将我重定向到索引页面。 I don't want to dig deeper just want to add an static link. 我不想更深入地研究,只是想添加一个静态链接。 Here is my .htaccess 这是我的.htaccess

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

您需要将其放在app / webroot目录中。

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. 如果要在CakePHP中添加需要通过Web浏览器访问的任何非Cake内容,则需要将其放置在webroot文件夹中,因为Cake的htaccess设置会重写所有其他URL。 (If you're using the older CakePHP 2 the webroot folder is in app ). (如果您使用的是较旧的CakePHP 2,则webroot文件夹位于app )。

You can put any php and call it from wherever you want. 您可以放置​​任何php,然后从任何地方调用它。

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. 在模板目录中,您将有一个元素目录-在其中创建一个FAQ目录,并在FAQ目录中创建一个名为faq.ctp的文件。

Then in the faq.ctp just drop in your php code, same as you would if writing in raw. 然后在faq.ctp中放入您的php代码,就像编写raw一样。

To call you can just call the element from whichever model you are in like so: 要调用,您可以仅从您所在的模型中调用元素,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM