Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:06:02+00:00 2026-06-08T10:06:02+00:00

Ive got a image cache system that im using to generate certain image sizes

  • 0

Ive got a image cache system that im using to generate certain image sizes as require. Im using modrewrite to check for the file and call the image creation system if it doesnt exist. The problem im having is that it is calling the image creation system even if the image does exist!

The modrewrite is simple enough (sites in the images sub directory)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /images/index.php?id=$1 [L,QSA]

I even tried removing the -d incase the directory check was confusing it. Ive now got it so that it checks the file exists inside the index.php code – which reports that it does.

I use the url images/cache/140x20/Test.JPG in the html – the file exists, so the RewriteCond should not call the index.php code – but it does for some reason?

Im sure its something obvious but i just cant figure it out

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:06:06+00:00Added an answer on June 8, 2026 at 10:06 am

    the .htaccess is in the images directory. Using R=302 i get the correct path expected http://www.domain.com/images/index.php?id=cache/140×20/Test.JPG

    That’s weird. I was testing under a subdirectory and was getting some unexpected values for %{REQUEST_FILENAME}. But I was able to get the check to work correctly by reconstructing from the document root. Maybe my understanding of %{REQUEST_FILENAME} or the underlying mechanism apache uses to make URI-path to file-path is different than what I expected.

    Try:

    RewriteCond %{DOCUMENT_ROOT}${REQUEST_URI} !-f
    RewriteCond %{DOCUMENT_ROOT}${REQUEST_URI} !-d
    # and maybe for good measure
    RewriteCond %{REQUEST_URI} !index.php
    

    EDIT:

    If your extensions are in all caps but the image filename extensions are always all lowercase, you can use a RewriteMap and define a map using the tolower function:

    (somewhere in your server or vhost config:

    RewriteMap lowercase int:tolower
    

    Then in your htaccess file (above your other rules), change the filenames to lowercase:

    # first check to make sure request doesn't already have all lowercase image extension
    RewriteCond %{REQUEST_URI} !\.(jpe?g|png|bmp|gif)$
    RewriteRule ^(.*)\.(jpe?g|png|bmp|gif)$ /$1.${lowercase:$2} [NC,L]
    

    You can also do something similar with the entire filename, or the entire path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got an assignment to create an image gallery using flickr - this has
ive got a file download issue can you help me for that... here is
Ive got a strange task. Specifically i want to check for insane media file
I've got an image that's allowed to be rotated and scaled by the user.
I've got a background image that changes to another image when :hover. I used
I've got a MySQL database that stores image information. Right now it only has
I'm working with an image caching system that generates different images based on a
I've got a view in Django that uses memcached to cache data for the
Ive got some C++ code, that we use to serialize arbitrary data and store
Ive got a website in a subdirectory but all the image, link and CSS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.