Reputation: 1745
I'm having a strange issue here.
I'm setting a session variable to the value of $_SERVER['REQUEST_URI']
on every page of my site except the login page. This way I can redirect the user back to whatever page they were on before logging in.
It works fine in every case, except recently I broke an image in my footer and the image 404
's. Now, $_SERVER['REQUEST_URI']
seems to be grabbing the URL of the image that's failing to load instead of the page the user was on, thus that my login form is now trying to redirect the user to the nonexistent image.
Obviously having files that fail to load is not ideal, but does anyone know why this server variable would be taking the value of the last failed request instead of the current page?
Upvotes: 0
Views: 321
Reputation: 4915
You have configured mod_rewrite
in .htaccess
to handle non-existent files by a php-script.
Since your image has disappeared, the URI matching to this image is also handled by this script that stores $_SERVER['REQUEST_URI']
to the session. So, it stores URI of requested page, and then rewrites it by requested and nonexistent image URI, because browser requests resources last.
To fix the problem you have to either filter URLs of images, css, javascript before storing them to session, or avoid situations to point to nonexistent resources from your resulting pages.
Upvotes: 2