Skip to content

Commit

Permalink
Merge pull request #72 from vlakoff/trailing-slash
Browse files Browse the repository at this point in the history
Remove redundant snippet, simplify title of the remaining one
  • Loading branch information
phanan committed Aug 26, 2015
2 parents cc10850 + 0b83618 commit cc4feb0
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ What we are doing here is mostly collecting useful snippets from all over the in
- [Force HTTPS Behind a Proxy](#force-https-behind-a-proxy)
- [Force Trailing Slash](#force-trailing-slash)
- [Remove Trailing Slash](#remove-trailing-slash)
- [Remove Trailing Slash from Arbitrary Paths](#remove-trailing-slash-from-arbitrary-paths)
- [Redirect a Single Page](#redirect-a-single-page)
- [Redirect Using RedirectMatch](#redirect-using-redirectmatch)
- [Alias a Single Directory](#alias-a-single-directory)
Expand Down Expand Up @@ -117,17 +116,11 @@ RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
```

### Remove Trailing Slash
``` apacheconf
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]
```

### Remove Trailing Slash from Arbitrary Paths
This snippet will redirect paths ending in slashes to their non-slash-terminated counterparts (except for actual directories), e.g. `http://www.example.com/blog/` to `http://www.example.com/blog`. This is important for SEO, since it’s [recommended](http://overit.com/blog/canonical-urls) to have a canonical URL for every page.
``` apacheconf
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteRule ^ %1 [R=301,L]
```
[Source](https://stackoverflow.com/questions/21417263/htaccess-add-remove-trailing-slash-from-url#27264788)

Expand Down

0 comments on commit cc4feb0

Please sign in to comment.