Menu

#63 URLParser messes up 301s through mod_rewrite

closed-fixed
nobody
WebKit (58)
5
2006-07-07
2004-02-22
Anonymous
No

I've been porting my site to WK CVS. I've found one
issue with the combination of mod_rewrite rules and the
new URLParser class. I am doing the standard /wk/
rewrite for the top level:
RewriteRule ^(.*) /wk/ [L,PT]

Now, say that I have a servlet at
http://example.com/directory/index (in reality
in /wk/directory/index). If I request:
http://example.com/directory/ everything works fine. If
instead though, I do an http://example.com/directory
(no trailing slash), the URLParser class (line 450 or so),
does this:
raise HTTPMovedPermanently
(webkitLocation=trans.request().urlPath() + "/")

That though sends to the client a 301 with a new
location of http://example.com/wk/directory/ which in
turn Apache changes into
http://example.com/wk/wk/directory/ which finally
raises a 404.

Changing the above URLParser line to:
raise HTTPMovedPermanently(location=trans.request
().urlPath() + "/")

fixes the problem, but I am not sure if that will break
other configs.

Discussion

  • Costas Malamas

    Costas Malamas - 2004-02-22

    Logged In: YES
    user_id=71233

    Sorry, I wasn't logged in; this is costasm@hotmail.com

     
  • Ben Parker

    Ben Parker - 2004-02-22

    Logged In: YES
    user_id=672635

    Even under the 0.8.1 release, there are situations where a
    double /wk can be prefixed by apache during a redirect.

    How about trying this rewrite rule instead:

    RewriteCond !^/wk
    RewriteRule ^(.*)$ /wk [L,PT]

    Then you'll never have apache adding 2 "/wk" prefixes to the
    URL, which I think is the real problem here.

    Regards,
    Ben

     
  • Christoph Zwerschke

    Logged In: YES
    user_id=193957

    Fixed in SVN trunk. SCRIPT_URL is evaluated to check for
    rewritten URLs. Will go into Webware 0.9.2.

     
  • Christoph Zwerschke

    • status: open --> closed-fixed
     

Log in to post a comment.