diff --git a/app/Response.php b/app/Response.php index 562fdc3..76da6ec 100644 --- a/app/Response.php +++ b/app/Response.php @@ -31,7 +31,7 @@ public function send(string $path): void $this->fetchFileContent($path); } - $content = $this->cache()->fetch($path); + $content = $this->cache()->fetch($key); $response = new SuccessResponse($content); $response->send(); } catch (Throwable $exception) { @@ -84,11 +84,13 @@ protected function checkIfPathIsAllowed(string $path): void } foreach ($paths as $pattern) { - if ($this->pathMatches($pattern, $path) === false) { - $response = new NotAllowedResponse($path); - $response->send(); + if ($this->pathMatches($pattern, $path) === true) { + return; } } + + $response = new NotAllowedResponse($path); + $response->send(); } protected function pathMatches(string $pattern, string $path): bool @@ -106,6 +108,6 @@ protected function getCacheKey(string $path): string { $host = parse_url($this->config["origin"]["base_uri"], PHP_URL_HOST); - return $host . "::" . $path; + return md5($host . "::" . $path); } } diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..b91ad92 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,17 @@ + + + Options -MultiViews -Indexes + + + RewriteEngine On + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Send Requests To Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] +