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 6331365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:03:03+00:00 2026-05-24T18:03:03+00:00

I am currently working on a filter in Grails that will allow me to

  • 0

I am currently working on a filter in Grails that will allow me to redirect all incoming requests on foo.org to the same subpage on foo.com.
So far I have been doing the following:

 if(!(""+request.requestURL).toLowerCase().startsWith(
             grailsApplication.config.grails.serverURL ))
    {redirect(url:"${grailsApplication.config.grails.serverURL}${request.requestURI}",params:params) }

Unfortunately, I am experiencing several issues in this approach:

  1. The request.requestURI value seems to behave differently than expected: instead of giving me the normal “/[controller]/[action]” pattern as I would expect, it returns something like: “/grails/[controller]/[action].dispatch”. – Is there an alternative way to obtain the “normal” URI? (excuse me if this is trivial, but have not been able to find it in the documentation, nor by trying out the various methods available on the request object)
  2. Params are not being passed in the above redirect. This is probably due to the fact that I am using the “url” parameter in the redirect which according to the docs is supposed to be used for redirects to absolute paths (which again causes it to ignore the params section?). However, since I will not be able to use the normal redirect(controller:…,action:…) approach when redirecting to another domain what approach could I use in order to pass the params correctly along to the subpage on foo.com ? Am considering a solution where I will add the params manually via a params.each{} closure, but isn’t there a more elegant solution to this?
  3. 301 redirects. Since my redirects are of a permanent nature, I would like to use the 301 status code. I have tried to set “response.status = 301” but it seems to be ignored when using the Grails redirect(…) method. Further I can see from grails.org that this seems to be introduced with grails 2.0, but is there a way to obtain this already now in Grails 1.3.7?
  • 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-05-24T18:03:04+00:00Added an answer on May 24, 2026 at 6:03 pm
    1. Use request.forwardURI.

    2. If you have meant GET params, then it should be resolved using the above URI?

    3. I think 301 redirects are not possible using classic redirect. You can do this in a filter like this, which is obviously not the cleanest way:

      def filters = {
          all(controller:'*', action:'*') {
              before = {
                  if (request.serverName == "foo.org") {
                      response.setStatus(301);
                      response.setHeader("Location", "http://foo.com" + request.forwardURI)
                      response.flushBuffer()
                      return false; // return false, otherwise request is handled from controller
                  }
              }
          }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on building a PHP based filter that will narrow down a
Am currently working on an application that requires users to submit posts and comments
I'm currently working on creating a new C# project that needs to interact with
I'm currently working on a wordpress 2.9.2 plugin (my first) that creates additional custom
I'm currently working on a project that requires me to match our database of
So I'm currently working on a project that needs to time when certain processes
I'm currently working on a program that analyses a wav file of a solo
I am currently working on my own implementation of a PNG Filter. I am
I am currently working on a Silverlight 4.0 Application that displays about 13.000 rows
I'm having some problems with the php script below that I'm currently working on.

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.