Your second example makes it plain what is happening: GET /cat.html HTTP/1.1 buffer = /cat.html path = /cat.html GET / HTTP/1.1 buffer = /cat.php path = /cat.phpl You are writing over the contents of the previous buffer without erasing them first. (Hence, the leftover "l" at the end of "/cat.phpl") This is not supposed to happen. It's hard to say exactly how to fix it without seeing any of your C source code, but two things spring to mind: * Are you remembering to `free()` everything that you `malloc()`? * When you allocate dynamic memory for your `abs_path` and `buffer`, have you tried using `calloc()` instead of `malloc()`, to zero out any garbage values remaining in the buffer?