From 63948d80645123c2935ccbad7f7ec23198b6e4f5 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 2 Feb 2017 21:03:09 +1300 Subject: [PATCH] Disable trailing slash redirect for dirs If you're running mod_dir on Apache, and create a route which matches a directory name (such as 'framework'), "GET /framework" will result in a 301 to "/framework/?url=framework". While the SilverStripe routing might decide to enforce trailing slash rules later, Apache shouldn't have any business here. The specific bug this fixes was redirecting "/graphql" to "/graphql/", with the silverstripe/graphql module installed. See https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryslash --- .htaccess | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.htaccess b/.htaccess index 81693c6..f2c9c2a 100644 --- a/.htaccess +++ b/.htaccess @@ -35,6 +35,7 @@ ErrorDocument 500 /assets/error-500.html # Turn off index.php handling requests to the homepage fixes issue in apache >=2.4 DirectoryIndex disabled + DirectorySlash Off SetEnv HTTP_MOD_REWRITE On @@ -42,18 +43,18 @@ ErrorDocument 500 /assets/error-500.html # Enable HTTP Basic authentication workaround for PHP running in CGI mode RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - + # Deny access to potentially sensitive files and folders RewriteRule ^vendor(/|$) - [F,L,NC] RewriteRule silverstripe-cache(/|$) - [F,L,NC] RewriteRule composer\.(json|lock) - [F,L,NC] - + # Process through SilverStripe if no file with the requested name exists. # Pass through the original path as a query parameter, and retain the existing parameters. RewriteCond %{REQUEST_URI} ^(.*)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* framework/main.php?url=%1 [QSA] - + # If framework isn't in a subdirectory, rewrite to installer RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$ RewriteCond %{REQUEST_FILENAME} !-f