如何在 cakephp 项目的 webroot 中 运行 php 文件
How to run php file in webroot of cakephp project
我想要 运行 php 文件,该文件位于 cakephp 2.5 项目的 webroot 文件夹中。
虽然 运行ning 我收到下面给出的错误
这里的 nghome 是放置在项目的 webroot 中的文件夹,我想执行 webroot/nghome/database.php 中的 database.php 文件,但是在执行该文件时我在它说找不到 nghome 控制器的地方出现错误。
任何帮助或建议将不胜感激,在此先感谢
检查您的 .htaccess 文件是否在 webroot 文件夹中工作
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
这一行RewriteCond %{REQUEST_FILENAME} !-f
负责执行现有文件。
并且还请求包括文件名 nghome/database.php
的完整路径
无需在 htaccess 或其他任何地方进行任何更改,只需在 webroot 中创建一个 php 文件 database.php
您就可以从浏览器访问它,例如 example.com/database.php
file path - app/webroot/filename.php
access from browser - example.com/filename.php
file path - app/webroot/somedir/filename.php
access from browser - example.com/somedir/filename.php
file path - app/webroot/somedir/subdir/filename.php
access from browser - example.com/somedir/subdir/filename.php
您可以 运行 您的 php 来自 webroot 的文件,方法是将您的文件放在 webroot 的 nghome 文件夹中,然后点击 URL 文件名。
我终于通过使用以下代码更新 webroot 文件夹下的 .htaccess 文件来完成这项工作
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我想要 运行 php 文件,该文件位于 cakephp 2.5 项目的 webroot 文件夹中。
虽然 运行ning 我收到下面给出的错误
这里的 nghome 是放置在项目的 webroot 中的文件夹,我想执行 webroot/nghome/database.php 中的 database.php 文件,但是在执行该文件时我在它说找不到 nghome 控制器的地方出现错误。
任何帮助或建议将不胜感激,在此先感谢
检查您的 .htaccess 文件是否在 webroot 文件夹中工作
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
这一行RewriteCond %{REQUEST_FILENAME} !-f
负责执行现有文件。
并且还请求包括文件名 nghome/database.php
无需在 htaccess 或其他任何地方进行任何更改,只需在 webroot 中创建一个 php 文件 database.php
您就可以从浏览器访问它,例如 example.com/database.php
file path - app/webroot/filename.php
access from browser - example.com/filename.php
file path - app/webroot/somedir/filename.php
access from browser - example.com/somedir/filename.php
file path - app/webroot/somedir/subdir/filename.php
access from browser - example.com/somedir/subdir/filename.php
您可以 运行 您的 php 来自 webroot 的文件,方法是将您的文件放在 webroot 的 nghome 文件夹中,然后点击 URL 文件名。
我终于通过使用以下代码更新 webroot 文件夹下的 .htaccess 文件来完成这项工作
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>