[play-20] Subdomain with Play 2.0

697 views
Skip to first unread message

Timothy Klim

unread,
Jun 11, 2012, 3:26:40 PM6/11/12
to play-fr...@googlegroups.com
Hi!

I read past topics and trying to use subdomain in my play app: app1.myapps.com:9000
with routes:
GET     {domain}.myapps.com/                   controllers.Apps.index(domain)

and I got other index page or error.

What I do wrong?

Timothy Klim

unread,
Jun 12, 2012, 7:20:22 AM6/12/12
to play-fr...@googlegroups.com
Is it really hard to do?

Todd O'Bryan

unread,
Jun 12, 2012, 11:13:16 AM6/12/12
to play-fr...@googlegroups.com
The routes path *starts* after the domain and port, so you can't
really (as far as I know) route based on the earlier stuff. If you
want to redirect based on that, you'd do it in your web server set-up,
not in Play. Apache lets you set up sub-domains and do rewriting.

Remember that the domain could be spelled out as a name or it could be
an IP address. What would you do if you got the wrong one?

Todd
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/V_zXmnf6vkwJ.
>
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

Otto

unread,
Jun 12, 2012, 11:32:01 AM6/12/12
to play-fr...@googlegroups.com
It's a question of convenience, especially in a  small setup / deployment getting rid of a webserver makes your life easier. Same is true for ssl support.

And to your question: Same behavior as apache, which has the same problem when you use an IP

Otto


On Tuesday, June 12, 2012 5:13:16 PM UTC+2, Todd O'Bryan wrote:
The routes path *starts* after the domain and port, so you can't
really (as far as I know) route based on the earlier stuff. If you
want to redirect based on that, you'd do it in your web server set-up,
not in Play. Apache lets you set up sub-domains and do rewriting.

Remember that the domain could be spelled out as a name or it could be
an IP address. What would you do if you got the wrong one?

Todd

On Tue, Jun 12, 2012 at 7:20 AM, Timothy Klim <klimt...@gmail.com> wrote:
> Is it really hard to do?
>
>
> On Monday, June 11, 2012 11:26:40 PM UTC+4, Timothy Klim wrote:
>>
>> Hi!
>>
>> I read past topics and trying to use subdomain in my play app:
>> app1.myapps.com:9000
>> with routes:
>> GET     {domain}.myapps.com/
>> controllers.Apps.index(domain)
>>
>> and I got other index page or error.
>>
>> What I do wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/V_zXmnf6vkwJ.
>
> To post to this group, send email to play-framework@googlegroups.com.
> To unsubscribe from this group, send email to

Guillaume Bort

unread,
Jun 12, 2012, 12:36:28 PM6/12/12
to play-fr...@googlegroups.com
You can't do that directly in the router in Play 2.0 anymore (and it is expected, it was a very bad idea). 

It is easy to handle via classical action composition and reading the request.host value. 
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/V_zXmnf6vkwJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

Timothy Klim

unread,
Jun 12, 2012, 1:29:48 PM6/12/12
to play-fr...@googlegroups.com
Ok, got it!


On Tuesday, June 12, 2012 8:36:28 PM UTC+4, Guillaume Bort wrote:
You can't do that directly in the router in Play 2.0 anymore (and it is expected, it was a very bad idea). 

It is easy to handle via classical action composition and reading the request.host value. 

On 12 juin 2012, at 13:20, Timothy Klim <klimt...@gmail.com> wrote:

Is it really hard to do?

On Monday, June 11, 2012 11:26:40 PM UTC+4, Timothy Klim wrote:
Hi!

I read past topics and trying to use subdomain in my play app: app1.myapps.com:9000
with routes:
GET     {domain}.myapps.com/                   controllers.Apps.index(domain)

and I got other index page or error.

What I do wrong?

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/V_zXmnf6vkwJ.
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.

Timothy Klim

unread,
Jun 12, 2012, 1:40:32 PM6/12/12
to play-fr...@googlegroups.com
Does it mean that each of programmer should reinvent the wheel in every project?
Can you include in play(further releases) some helpers for working with subdomains?

Thank you.


On Tuesday, June 12, 2012 8:36:28 PM UTC+4, Guillaume Bort wrote:
You can't do that directly in the router in Play 2.0 anymore (and it is expected, it was a very bad idea). 

It is easy to handle via classical action composition and reading the request.host value. 

On 12 juin 2012, at 13:20, Timothy Klim <klimt...@gmail.com> wrote:

Is it really hard to do?

On Monday, June 11, 2012 11:26:40 PM UTC+4, Timothy Klim wrote:
Hi!

I read past topics and trying to use subdomain in my play app: app1.myapps.com:9000
with routes:
GET     {domain}.myapps.com/                   controllers.Apps.index(domain)

and I got other index page or error.

What I do wrong?

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/V_zXmnf6vkwJ.
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.

Guillaume Bort

unread,
Jun 12, 2012, 2:46:14 PM6/12/12
to play-fr...@googlegroups.com
Reinvent the wheel? You mean, write the regex that matches its domain pattern?
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/yqU4K3HSOLgJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.

Timothy Klim

unread,
Jun 12, 2012, 2:48:52 PM6/12/12
to play-fr...@googlegroups.com
How about link helpers?

Timothy Klim

unread,
Jun 12, 2012, 2:51:26 PM6/12/12
to play-fr...@googlegroups.com
For example: @routes.Application.index.withSubdomain("easy") - why not?

James Roper

unread,
Sep 26, 2012, 8:35:50 PM9/26/12
to play-fr...@googlegroups.com
Tying your code to a particular domain name makes it very difficult to test, either in development, or in a test environment.

On Thursday, 27 September 2012 00:57:00 UTC+10, John Castle wrote:
Just curious, why is it a bad idea to do that in Play! ?
Reply all
Reply to author
Forward
0 new messages