I made an ajax website that call php pages from /pages folder inside my index.php
, so i made a rewrite in htaccess
for return all my pages in my index so the ajax working well but when clicking refresh the page button or on first load, the function can't find files, return 404.php
page all the time:
This is my htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9\-]*).php$ index.php?p=$1 [L]
And this is my php function calling my pages:
<div id="ajax-container">
<?php
$d = "pages/";
if (isset($_GET['p'])) {
$p = strtolower($_GET['p']);
if (preg_match("/^[a-z0-9\-]+$/", $p) && file_exists($d . $p . ".php")) {
include $d . $p . ".php";
} else {
include $d . "404.php";
}
} else {
include $d . "home.php";
}
?>
</div>
I think the problem come from my rewrite because it's rewrite all pages php so I think it's also rewriting my index.php
and so the function can't find the ['p']
but I'm not sure and I don't know if it's this how can I rewrite only files from my /pages
folder