1

I'm creating a php front-controller because I need to include file from other folders instead of creating the same file for those that have the same content

Example of a directory structure

rome
  - index.php
  - detail.php
  - show.php

another folder

london
  - index.php (same content as rome/index.php folder)
  - detail.php (different content as rome/detail.php folder)
  - show.php (same content as rome/show.php folder)

Then london folder must include only detail.php that have different content from rome/detail.php and "index" and "show" must be loaded from rome folder

And this is my htaccess / front-controller

.htaccess

RewriteEngine On
RewriteRule . /front-controller.php [L]

front-controller.php

path = "{$_SERVER['DOCUMENT_ROOT']}$_SERVER['REQUEST_URI']}"; 
if (! file_exists ($path) ) include str_replace("london" , "rome" , $path ); 

The now I have problem for that file that include other content...

For example, my rome/index.php have

include 'content/header.php'

And when I load london/index.php I have the error

'content/header.php' failed to open stream: No such file or directory

EDIT

these are the error

Warning: require(content/php/config.php): failed to open stream: No such file or directory in /home/debian/www/rome/content/php/start.php on line 17

Fatal error: require(): Failed opening required 'content/php/config.php' (include_path='.:/usr/share/php:/usr/share/pear:') in /home/debian/www/rome/content/php/start.php on line 17 
FireFoxII
  • 828
  • 4
  • 18
  • 31
  • 1
    I have tried to reproduce the error but it works :D Can you print the path of the file you are trying to include? – Piotr Dawidiuk Jan 25 '17 at 17:53
  • In the original post I have added the error – FireFoxII Jan 25 '17 at 18:33
  • Visit here if you can... http://stackoverflow.com/questions/41970755/php-front-controller-to-include-file-from-other-folder-if-not-exist .. If you reproduce, you have the same error – FireFoxII Feb 01 '17 at 02:02

0 Answers0