G
G
gregorypetrov2017-05-30 12:15:33
Web servers
gregorypetrov, 2017-05-30 12:15:33

Is it possible to somehow determine on the server whether the image was called by the URL through the address bar, or was requested by the browser when rendering the page?

Good afternoon, colleagues!
The following task was set: when a user calls a non-existent image in the address bar ( example.com/images/nonexistent.png ), he needs to be redirected to the main page of the site.
It seems to me that there is an unresolvable contradiction here - if you do this (also a question - how and through what?), Then when you try to draw a non-existent image on any page, the server will try to send ...redirects to the main page in the headers.
Or is it possible to somehow distinguish whether an image is requested in the context of rendering the page or in the address bar of the browser (apparently not, as far as I know...)
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-05-30
@gregorypetrov

Referrer header.
When loading from a page, there will be a page address.
When loaded directly, it will be empty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question