Hello, I'm new here and I have no experience with with mod rewrite / clean url.
I want to clean my urls with php instead of mod rewriting. I only need mod rewrite to redirect all request to index.php.
index.php: (part of it)
$url = strip_tags($_SERVER['REQUEST_URI']);
$url_array = explode("/",$url);
array_shift($url_array);
if (!empty($url_array[0])) {
if (file_exists('pages/'.$url_array[0].'.php')) {
include('pages/'.$url_array[0].'.php'); }
else {
include('pages/error404.php'); }
}
else {
include('pages/home.php'); }
.htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Links on the homepage (index.php) are working.
Example, <a href="example">Example</a> redirect to "http://www.mysite.com/example" and show the correct page.
On this page (http://www.mysite.com/example) links such as <a href="example/test">Test</a> are not working properly.
The url in the browser is correct (http://www.mysite.com/example/test), but no images, js and css are loaded.
A link on this page (http://www.mysite.com/example/test) like <a href="home">Home</a> isn't working either and redirect to
"http://www.mysite.com/example/home" instead "http://www.mysite.com/home"
In map 'pages' the file "example.php" exist. File "test.php" does not exist and is virtual.
I cannot figure it out?