301 redirection

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
4/4/2010 5:47:13 PM
Gravatar
Total Posts 2

301 redirection

Not really a Bug but I didn't find any other forum to post.

I'm running 2.3.4.1 with SQL and when using the 301 redirection I found that QueryString parameters are not included in the redirection. Since my page receives some parameters to work this was causing some issues.

To solve it I modified the Do301Redirect and it works really well.

instead of

app.Context.Response.AddHeader("Location", siteRoot + "/" + newUrl);

use this

app.Context.Response.AddHeader("Location", siteRoot + "/" + newUrl + app.Request.Url.Query);

Hope this helps

4/5/2010 9:52:15 AM
Gravatar
Total Posts 18439

Re: 301 redirection

Hi Cristofer,

I can see where this would come in very handy in some situations like where the new page uses the same query string params, but not sure this is desirable in all cases. If the new page does not use the params it could hurt the SEO of the new page.

I made this change in my copy for the next release:

if (WebConfigSettings.PassQueryStringFor301Redirects)
            {
                app.Context.Response.AddHeader("Location", siteRoot + "/" + newUrl + app.Request.Url.Query);
            }
            else
            {
                app.Context.Response.AddHeader("Location", siteRoot + "/" + newUrl);
            }

so it will be possible to enable your scenario by adding a config setting while keeping the current behavior as the default.

Best,

Joe

4/10/2010 1:43:34 PM
Gravatar
Total Posts 2

Re: 301 redirection

Completely agree with your approach.

Thanks, you're doing a great job

You must sign in to post in the forums. This thread is closed to new posts.