Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mariussoutier/play-trailing-slash

Automatically 401 redirect routes with a trailing slash to a route without a trailing slash
https://github.com/mariussoutier/play-trailing-slash

Last synced: about 6 hours ago
JSON representation

Automatically 401 redirect routes with a trailing slash to a route without a trailing slash

Awesome Lists containing this project

README

        

Play Trailing Slash
===================

What is this?
-------------

This is a Play Framework 2 module that generates a 401 Moved Permanently redirect for request
paths that end with a slash, redirecting to a path without a trailing slash.

Why is this useful?
-------------------

Consider a simple URL such as http://www.example.com/login that displays a login page. If the user
enters http://www.example.com/login/ by accident, Play will generate a 404 result. If you define both
routes, Google will treat this as duplicate content. Play's default router only offers a 302 redirect
which doesn't solve the duplicate content problem.

How do you use it?
------------------

Build.scala:

val trailingSlash = RootProject(uri("git://github.com/mariussoutier/play-trailing-slash.git"))
val main = play.Project(...).dependsOn(trailingSlash)

Scala:

import com.mariussoutier.play._
object Global extends GlobalSettings with TrailingSlash

Java:

import com.mariussoutier.play.*;
public class Global extends TrailingSlashSettings {
}