Framework Only in backend and front end have a Non-cakephp site... this front end must reside in webroot

cakephp[or other framework] public site document root of domain must be in webroot… well what if use cakephp Only in backend and front end have a Non-cakephp site… this front end must reside in webroot??? note front end linked to database withOut cakephp…but using plain PHP PDO queries…

Most if not all PHP Frameworks are called from index,php which resides in the root.

Normally .htaccess is used to rewrite all not found $_SERVER['REQUEST_URI']'s to index.php

Try renaming your index.php file to “My-Backend.php” and test to see if your PHP Framework is called.

so in other words
all files from web site (non-cakePHP) must uploded to /webroot/… this after renaming index.php to backend.php

correct?

after have to modify >>>>??? // here is .htaccess

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

how notify php framework that changed index.php, to backend.php
???

Take a look at your config.php
CodeIgniter

#http://stackoverflow.com/questions/31418935/codeigniter-no-uri-present-default-controller-set
# Not necessary to set URL - can leave blank
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'] .'/'; // '';
#$config['base_url'] = '';
 
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'My-backend.php'; // 'index.php';
...
...
1 Like

This is not required and only necessary for Pretty Urls"

**My-backend.php" will call your PHP Framework.

1 Like

You mean in cakePHP is a single line change and all other scripts follow this???
/webroot/
/index.php

/index.php in project - Not in webroot/

require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';

Did you try changing index,php to My-backend.php?

If it did not work have a look at your config.php and see if there is any relative information.

1 Like

If i’m getting this right, what you’re trying to say is that you need your php application hosted on some server (the root path is irrelevant here) and your front-end could be elsewhere, right? Then there’s no need for changes in .htaccess file or whatever. The answer to your question relies in this question: Is it possible to configure cross domain access for the front-end to be able to communicate with cakephp? If it is indeed possible, then you can host your front-end wherever you want, otherwise the front-end must be under the same domain of the application, not at the same folder necessarily. Maybe if you give us more details about what you’re about to do we can help you further.

I tried rename
require ‘webroot’ . DIRECTORY_SEPARATOR . ‘index-rename.php’;
and change name of file but doesn’t work… ? what to do?

http://localhost/adminDashboard/ // cakePHP backend

http://localhost/www/index.php // front end No cakePHP only PDO connect to db

how upload to same server? **http://localhost/adminDashboard/webroot/**index.php // public folder i guess

http://localhost/adminDashboard/
index.php

require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';

http://localhost/adminDashboard/.htaccess

# Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
#    RequestHeader unset Proxy
#</IfModule>

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

http://localhost/adminDashboard/webroot/index.php


if (php_sapi_name() === 'cli-server') {
    $_SERVER['PHP_SELF'] = '/' . basename(__FILE__);

    $url = parse_url(urldecode($_SERVER['REQUEST_URI']));
    $file = __DIR__ . $url['path'];
    if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) {
        return false;
    }
}
require dirname(__DIR__) . '/vendor/autoload.php';

use App\Application;
use Cake\Http\Server;

// Bind your application to the server.
$server = new Server(new Application(dirname(__DIR__) . '/config'));

// Run the request/response through the application
// and emit the response.
$server->emit($server->run());

http://localhost/adminDashboard/webroot/.htaccess

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

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.