Skip to content

Commit 68de7b3

Browse files
Trailing slash redirect should retain the HTTP method (#1820)
1 parent 15677f4 commit 68de7b3

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

content/collections/tips/trailing-slashes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Add this to your `.htaccess` file:
2727
RewriteEngine On
2828
RewriteCond %{REQUEST_FILENAME} !-f
2929
RewriteCond %{REQUEST_URI} !(.*)/$
30-
RewriteRule ^(.*)$ /$1/ [R=301,L]
30+
RewriteRule ^(.*)$ /$1/ [R=308,L]
3131
```
3232

3333
### Nginx
@@ -36,11 +36,11 @@ Add this to your `server` block:
3636

3737
```
3838
location / {
39-
if (!-f $request_filename) {
40-
rewrite ^/(.*)([^/])$ /$1$2/ permanent;
39+
if ($request_uri ~ "^[^?\\.]*[^/]$") {
40+
return 308 $request_uri/;
4141
}
4242
try_files $uri $uri/ /index.php?$query_string;
43-
}
43+
}
4444
```
4545

4646
### IIS
@@ -57,7 +57,7 @@ Add this to your `web.config` file:
5757
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
5858
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
5959
</conditions>
60-
<action type="Redirect" url="{R:1}/" redirectType="Permanent" />
60+
<action type="Redirect" url="{R:1}/" redirectType="Permanent308" />
6161
</rule>
6262
</rules>
6363
</rewrite>

0 commit comments

Comments
 (0)