I'm trying to create website using a router in PHP which is in a Public folder.
I want to use Ajax to load my files,
have the impression that my htaccess blocks my code, and when I execute an Ajax call, it does not find my PHP file, and i have 404 error with this file:
404 error
here is the project architecture:
project architecture
Here my index.php
define("ROOT", dirname(__DIR__));
require ROOT . "/Config/InitAdmin.php";
AppAutoloader::register();
$url = "";
if (isset($_GET["url"])) {
$url = $_GET["url"];
}
ob_start();
if ($url == "") {
require ROOT . "/Pages/Home.php";
} elseif ($url == "Account") {
require "../Pages/Account.php";
} elseif ($url == "Users" || $url == "Users.php") {
require "../Pages/Users.php";
} else {
require "../Errors/404.php";
}
$content = ob_get_clean();
require_once ROOT . "/Pages/Includes/Layout.php";
here my htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} /Public/([^s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!Public/).*)$ Public/Index.php?url=$1 [L,NC]
And here my Js file :
$(document).ready(function () {
/*
# --> View Data
*/
load_data();
function load_data(page) {
$.ajax({
url: "../../Src/Users/AffichageUsers.php",
method: "post",
data: { page: page },
success: function (data) {
$('#table').html(data);
}
})
}
$(document).on('click', '.pagination_link', function () {
var page = $(this).attr('id');
load_data(page);
})
})
can you help me please?