Named anchor passed in URL resulting in 404 error

Discussion in 'Bug Reports' started by dcanali, Oct 18, 2011.

  1. dcanali

    dcanali New Member


    first of all, I apologize if my post is not in the appropriate section of the forum. In fact, I think this is not a real bug even though in my opinion it affects the reliability of the webserver.

    I realized that in Litespeed, issuing a http request with an URL in which the anchor part has not been removed, results in a 404 error.
    The same request, issued, for example, to an Apache2 webserver, correctly returns the page corresponding to the resource.

    e.g., issuing a GET to:
    results in a 404 even if the page existing_resource.php exists.

    I know that, by specification, it's the web client that should take care of "cleaning up" the URL and removing parts, such as anchors, that are used only for layout purposes, but some of them (e.g., curl) don't do any URL processing.
    Even if the client does not sufficiently clean up the URL, I think it would be a safe idea to strip out eventual anchor parts that are left behind.

    I found out the problem using curl on a Wordpress forum hosted on a Litespeed webserver. Wordpress often uses 302 redirects to send a user to a specific page anchor after a post, but specifying the redirect as "Location: page#comment" was making every request with curl fail.

    Thank you,

    Davide Canali
  2. NiteWave

    NiteWave Administrator

    as a workaround, you can use rewriterule to strip tailing #xxx

    for example in document .htaccess:
    RewriteRule (.*)#(.*)$ $1
  3. dcanali

    dcanali New Member

    Yes, thank you, this should work (even though it would be better for the webserver to handle it).

Share This Page