Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8809729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:56:57+00:00 2026-06-14T02:56:57+00:00

In play framework 1, you could use in the routes file something like this

  • 0

In play framework 1, you could use in the routes file something like this (check documentation at http://www.playframework.org/documentation/1.2.5/routes#syntax)

GET     /clients/?       Clients.index

so that the route will match /api/clients and also /api/clients/

How can I achieve the same in play framework 2?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:56:59+00:00Added an answer on June 14, 2026 at 2:56 am

    From SEO point of view the same link with trailing slash is other one than link without it. It is highly recommended to always use one schema (trailed or un-trailed links).

    Although there are different schools which one is better the most important is to make a 301 redirect from ‘wrong’ URL to the correct. You can achieve it quite easy in Play with a ‘Dynamic part spanning several /‘.

    Personally I prefer un-trailed version, maybe because implementing it in the Play is just like writing few simple lines. Add to your routes file this rule, somewhere at the beginning (keep the slash – it’s important as it’s NOT considered as next slash in the spanning-group, and allows to match trailed URL’s easily):

    GET  /*path/  controllers.Application.untrail(path: String)
    

    then you can just make a redirect in the controller – to the param, so it will be without the slash at the end:

    Java

    public static Result untrail(String path) {
       return movedPermanently("/" + path);
    }
    

    Scala

    def untrail(path: String) = Action { 
      MovedPermanently("/" + path)
    }
    

    Until now, all routes ending with the slash will be redirected to the un-trailed version. Easy 🙂

    Of course it’s highly recommended to use reverse router for generating correct URL’s – to minimalize redundant redirects. Also if you’re hardcoding the URL somewhere (ie. in some JS or in external application) it’s also better to write correct ones instead converting them every time. If you’re planning to publish some public API make a note in documentation, which pattern does your application prefer, so developers will be warned and (maybe) will prepare correct calls.

    What’s more – it most important for GET routes as they are a subject to manipulation from the client’s side. While using POST, PUT, DELETE and others you don’t need (or rather, you should’t) to care about redirects as they can not be changed by the user and in that way you need to remember which way you choose. In case of wrong call ie. for POST, just return a 404 error – so the developer of the 3-rd part application will be obligated to use correct endings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Play Framework, you can do something like this: public static void mymethod() {
I'm building some crude CMS-like functionality (to get acquinted with Play Framework). For this
I am brand new to the play framework and could use a little bit
I recently stumbled upon Play framework while evaluating frameworks to use in a project.
I'm following the Play Framework 2.0 tutorial for Java and get this error when
I have this play framework 2 code (simplified): import formatters.json.IdeaTypeFormatter._ object IdeaTypes extends Controller
I am trying to use Play 2.0 RC3. I have extracted the framework into
In Play Framework 1.x, we could quickly know if the request was AJAX or
I have a structure like this WebUI project - controllers, views Framework project- repositories,service
Basically I started to design my project to be like that: Play! Framework for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.