Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I was working on my node server and encountered the need to implement the use of request.headers.referer. When I did tests and read headers to determine how to write the parsing functions, I couldn't determine a differentiation between requests that invoke from a link coming from outside the server, outside the directory, or calls for local resources from a given HTML response. For instance,

Going from localhost/dir1 to localhost/dir2 using <a href="http://localhost/dir2"> will yield the response headers:

referer:"http://localhost/dir1" url:"/dir2"

while the HTML file sent from localhost/dir2 asking for resources using local URI style.css will yeild:

referer:"http://localhost/dir2" url:"/style.css"

and the same situation involving an image could end up

referer:"http://localhost/dir2" url:"/_images/image.png"

How would I prevent collisions in the resolution, between url and referer, from accidentally resolving to and being parsed as http://localhost/dir1/dir2 or http://localhost/_images/image.png and so on? Is there a way to tell in what way the URI is being referred by the browser, and how can either the browser or server identify when http://localhost/dir2/../dir1 is intended destination?

share|improve this question

closed as off-topic by womble, Michael Hampton Aug 14 at 2:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – womble, Michael Hampton
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.