• Some browsers seam to pass the named anchor with the http request (i.e. “GET /blog/#foo HTTP/1.1” ). When the broswer does this, WordPress refuses to ignore the #foo and gives a 404 instead. This is difficult to test since most browsers quietly drop the named anchor when giving the request to the server.

    I see the problem in my access logs and I have successfully reproduced it using the tool ‘curl’ (in linux) which happily passes the anchor along to the server:
    127.0.0.1 - - [23/Oct/2006:16:29:31 -0700] "GET /blog/2006/10/16/mooney-homecoming/#respond HTTP/1.1" 404 5243 "-" "curl/7.12.3 (i386-redhat-linux-gnu) libcurl/7.12.3 zlib /1.2.2.2 libidn/0.5.6"

    Feel free to test it out (foobert.ath.cx/blog/2006/10/16/mooney-homecoming/#respond), but take note that MOST newer browsers hide this issue as listed above by not passing the #respond — something you won’t know without looking at the server access log.

    One other tidbit — it seams that this has been condidered already (and safeguarded — at least some of the time) by the function ‘url_to_postid’ where:
    // Get rid of the #anchor
    $url_split = explode('#', $url);
    $url = $url_split[0];

    Additional info: I’m running apache 2.0.53, php 4.3.11, and WP 2.0.4.

    My .htaccess has:

    php_flag session.use_trans_sid off
    <IfModule mod_rewrite.c>
    Options +Followsymlinks
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

    Thank you in advance for the help!

    PS — this was wrongly posted to a different category — my appolgies for having fat fingers the first time.

  • The topic ‘Named anchors causing 404’ is closed to new replies.