diff --git a/index.php b/index.php index 452ae66..bb9fe22 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ format('c'))); - exit; + // Redirect, with the "+" replaced by "_" + header('Location: /' . str_replace('+', '_', $dateObj->format('c'))); + exit; } elseif ($_SERVER['REQUEST_URI'] !== '/') { + // -- Show date infos // Remove leading "/" $req = substr($_SERVER['REQUEST_URI'], 1); - // -- Show date infos - // First check if date is following the format + // Check if date is following the format $re = '/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[\_|-]\d{2}:\d{2}$/'; if (!preg_match($re, $req)) { http_response_code(404); @@ -92,7 +94,7 @@ try { } } catch (Exception $e) { http_response_code(400); - $error = 'Invalid date format or date out of range.'; + $error = 'Date is not valid, or wrong format.'; } ?> @@ -192,7 +194,7 @@ try {