Neeraj Rathod
Neeraj Rathod

Reputation: 1665

How to run php file in webroot of cakephp project

I want to run php file which is placed in webroot folder of cakephp 2.5 project. while running that i am getting error given below enter image description here

Here nghome is the folder which is placed in webroot of the project and i want to execute a database.php file which is in webroot/nghome/database.php but while executing that file i am getting error where it says nghome controller is not found.

any help or suggestion will be appreciated , thanks in advance

Upvotes: 2

Views: 2935

Answers (4)

Neeraj Rathod
Neeraj Rathod

Reputation: 1665

I finally got this working by updating .htaccess file under webroot folder with below code

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Upvotes: 1

Manish Singh
Manish Singh

Reputation: 26

You can run your php file from webroot by putting your file in nghome folder in webroot and hit the URL with file name.

http://www.example.com/nghome/filename.php

Upvotes: 0

dav
dav

Reputation: 9267

There is no need to make any changes in htaccess or anywhere else, simply creating a php file database.php inside webroot you can access it from browser like 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

Upvotes: 1

Yakng
Yakng

Reputation: 135

check your .htaccess file working or not inside webroot folder

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

This line RewriteCond %{REQUEST_FILENAME} !-f is responsible for executing existing files. And also request full path including file name nghome/database.php

Upvotes: 0

Related Questions