简体   繁体   中英

Multiple Domains on single grails application and second domain only with access to one specific controller?

I have a grails 2.2.2 application and i want to have two domains connected with it. Domain.tld and shop.domain.tld.

Requests over domain.tld aren't allowed to access to ShopController. Only shop.domain.tld should have access to ShopController, but to no other Controller of the application.

I also want to use the grails url-rewriting. Is there a possibility to implement such use-case with grails? If yes, how would you implement it?

In the end i want that for example each online shop can be accessed by shop.domain.tld/ID

and not by domain.tld/shop/myShop/ID. domain.tld is supposed to other purposes.

Thanks and best regards

If both domain points to the same server, and Tomcat is used for both as your public facing web server, then you just need to modify the part inside your Grails.

In Controller, you can check which domain was used to access your application:

def uri = new java.net.URI(request.getHeader("referer"))
def domainName = uri.getHost()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM