Ik heb een router welke de juiste pagina pakt uit een mapje op mijn server. Dit werkt perfect als men de site gebruikt via https://www.... en ook als iemand zonder https en www het domein typt dus bijvoorbeeld: 123gemaakt.nl ipv www.123gemaakt.nl of https://www.123gemaakt.nl Dit werkt perfect maar als men dit typt:
123gemaakt.nl/pagina/offertes-aanvragen dan wordt die redirect naar https://www.123gemaakt.nl/index.php
Weet iemand waarom dit is? Dit is de php code:
<?php
function loadContent()
{
//Remove request parameters:
list($path) = explode('?', $_SERVER['REQUEST_URI']);
//Remove script path:
$path = substr($path, strlen(dirname($_SERVER['SCRIPT_NAME']))+1);
//Explode path to directories and remove empty items:
$pathInfo = array();
foreach (explode('/', $path) as $dir)
{
if (!empty($dir))
{
$pathInfo[] = urldecode($dir);
}
}
if (count($pathInfo) > 0)
{
//Remove file extension from the last element:
$last = $pathInfo[count($pathInfo)-1];
list($last) = explode('.', $last);
$pathInfo[count($pathInfo)-1] = $last;
}
$content = basename($path);
if ($content == '')
{
include './pagina/home.php';
}
elseif ($content != '')
{
$content .= '.php';
if(file_exists('./pagina/'.$content))
{
include './pagina/'.$content;
}
else
{
include './pagina/404.php';
}
}
}
?>
En dit is de htaccess code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L,QSA]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress