e107help.org Q&A
0 like 0 dislike

I have a page that references a JPG image file in a directory outside of the "\media\" and "\theme\img" directories.

If this image doesn't exist, I'd expect the server to return a HTTP 404 response - but it doesn't, it redirects to the index.php page and returns HTTP 200.

That wouldn't be a major issue, except the index.php page does some database intensive work, and I don't want an absent image file to trigger a rendering of index.php, especially since it will never even be seen.

I've looked inside of the .htaccess file (my understanding of htaccess is essentially non-existent), and this behaviour seems to be determined by this line:

### Single entry point ###
    RewriteRule .* index.php [L]

But I see some other lines that appear to make special provision for certain types of file a little further up:

### send 404 on missing files in these folders
    RewriteCond %{REQUEST_URI} !^/(e107_images|e107_files)/
    RewriteCond %{REQUEST_URI} !\.(css|js|swf|mp3|mp4|eot|otf|ttc|ttf|woff|woff2)$ [NC]

If I modify the second line as below, then I get my 404 error (for the JPG file):

RewriteCond %{REQUEST_URI} !\.(css|js|swf|mp3|mp4|eot|otf|ttc|ttf|woff|woff2|jpg)$ [NC]

That's OK, I suppose, I mean I can do that for the image types I need to work with. But I don't know whether this will have any unforseen consequences. Are image files excluded from this group for any particular reason (though, given how many there are, it would be a long list)?

Otherwise, is there something else I'm overlooking that would provide a simpler solution? Thanks in advance

e107 version Version 2.1.8 (git)
in Core by (87 points) 4 9 14
closed by

1 Answer

1 like 0 dislike
Best answer
Unsure, but likely no consequences as it (should) only reflect what type is missing.

However mind line 1 it will use (solemly) the paths given there, so you would need to add the folder where those images (as mentioned outside), to that line also.

Because particular change, tests would give you the outcome.
by (3.4k points) 8 9 11
selected by
Thank you for your reply, that's helpful
996 questions
1,389 answers
2,512 users