Update versions.php and htaccess.conf

This commit is contained in:
2024-10-26 18:19:18 +02:00
parent 1a75e0b22f
commit c514d8e097
9 changed files with 151 additions and 12 deletions

View File

@@ -79,6 +79,44 @@ if ( \S::get( 'action' ) == 'htaccess' )
exit;
}
// check redirects
$request_uri = substr( $_SERVER[ 'REQUEST_URI' ], 1, strlen( $_SERVER[ 'REQUEST_URI' ] ) );
if ( $request_uri != '' )
{
$new_url = $mdb -> get( 'pp_redirects', 'to', [ 'from' => $request_uri ], [ 'ORDER' => [ 'date_add' => 'DESC' ] ] );
if ( $new_url['to'] )
{
header( 'Location: ' . $new_url[ 'to' ], true, 301 );
exit;
}
}
// check routes
$request_uri = ltrim( $_SERVER['REQUEST_URI'], '/' );
if ( $request_uri != '' )
{
$matched = false;
$routes = $mdb -> select( 'pp_routes', '*' );
foreach ( $routes as $route )
{
$pattern = $route['pattern'];
$destination = $route['destination'];
if ( preg_match("#^" . $pattern . "#", $request_uri, $matches ) )
{
// Replace placeholders in the destination with matches from the request URI
$destination = preg_replace( "#^" . $pattern . "#", $destination, $request_uri );
// Parse the destination string to extract GET parameters
parse_str(parse_url($destination, PHP_URL_QUERY), $_GET);
$matched = true;
break;
}
}
}
if ( \S::get( 'a' ) == 'page' and \S::get( 'id' ) )
{
$page = \front\factory\Pages::page_details( \S::get( 'id' ) );