#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    51
    Rep Power
    46

    Rewrite works but server responds with 404


    Hi,

    I have a rewrite similar to ths:

    Redirectrule ^member/(.*)$ /members/memberinfo.php?name=$1 [L,NC]

    If for example i visit mydomain.com/member/john-may/ It is working fine, however in the console of my browser I can see that the HTTP response code to my request is 404.

    I suspect that even though apache does the rewrite correctly, at the same time it tries to find the directory /member/john-may/ and it fails because it doesn't exist?

    Any ideas?
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,395
    Rep Power
    9645
    a) The rewrite is not working and you have an ErrorDocument somewhere that makes it look like the request is working. Don't use ErrorDocuments that way.
    b) The rewrite is working and memberinfo.php (or some other code) is sending the 404, not Apache.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    51
    Rep Power
    46
    thanks for your reply.

    The (a) is definitely not the case because I see the content returned from memberinfo.php which is dynamic so It cannot - not - be working since Im seing the updated content.

    Regarding the (b) how can it be sending 404 along with the correct content?

    thanks
  6. #4
  7. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,395
    Rep Power
    9645
    I don't know. That's a question for you to answer - by looking through your codebase to see if you can find it.

    Unless there's more to this than what you posted. Like, "RedirectRule" is incorrect: it should be "RewriteRule". So maybe you didn't actually post what your rewriting rules are?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    51
    Rep Power
    46
    Ok I will check the script again.

    The rewrite rule is the one I posted, I just typed it instead of copy it and I mistakenly wrote RedirectRule instead of RewriteRule. Other than that its the same.
  10. #6
  11. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,395
    Rep Power
    9645
    If there's no ErrorDocument or any rewriting with a R=404 in there then it must be due to something in code.

IMN logo majestic logo threadwatch logo seochat tools logo