Update htaccess to include rewrite rules for non-existing files and directories

This commit is contained in:
2024-10-27 21:49:59 +01:00
parent c514d8e097
commit cbdf464599
2 changed files with 6 additions and 1 deletions

View File

@@ -769,6 +769,11 @@ class S
$htaccess_data );
}
$htaccess_data .= PHP_EOL;
$htaccess_data .= 'RewriteCond %{REQUEST_FILENAME} !-f' . PHP_EOL;
$htaccess_data .= 'RewriteCond %{REQUEST_FILENAME} !-d' . PHP_EOL;
$htaccess_data .= 'RewriteRule ^ index.php [L]';
$fp = fopen( $dir . '.htaccess', 'w' );
fwrite( $fp, $htaccess_data );
fclose( $fp );

View File

@@ -103,7 +103,7 @@ if ( $request_uri != '' )
$pattern = $route['pattern'];
$destination = $route['destination'];
if ( preg_match("#^" . $pattern . "#", $request_uri, $matches ) )
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 );