I have a project with so many php includes and requires , when i downloaded all the file from the server to my localhost , the pages where not loading correctly , i found out it was because of the path in include and require funtions
when i gave in my view file
require 'models/topic_db.php';
its working correctly but my folder is actually like this admin/models/topic_db.php
and in my view file is at admin/views/topic.php
and in my server it works like this
require '../models/topic_db.php';
I dont understand what the issue is , but all the pages are having similar issue so i can't go to each page and fix it , so i need a common solution , is there a way i can fix it without editing each and every file ?
for the record this is also working require(dirname(__DIR__).'/models/topic_db.php');
But in all my codes the format is like this require '../models/topic_db.php';
Any way i can fix it using .htaccess ?
Right now my .htaccess looks like this
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.php$ index.php [NC]
And my project is at
C:\xampp\htdocs\live\project
Image to get an idea of the folder path
<?php
session_start();
//include ('../../config.php');
include(dirname(__DIR__).'../config.php');
require_once(dirname(__DIR__).'../system/core/coreModel.php');
//require_once '../../system/core/coreModel.php';
$db = new coreModel();
$conn = $db->connectDb();
?>