0

I am trying to use adaptive images on my local wamp server. The ai-cache folder is not showing up and the images are not being replaced at all. As per this thread I tried RewriteRule .(?:jpe?g|gif|png)$ test.jpg in the .htaccess file and add test.jpg in the same folder but that doesn't change anything.

In the wamp menu Apache->Apache Modules->rewrite_module is checked and it is uncommented in httpd.conf LoadModule rewrite_module modules/mod_rewrite.so

I restart all services in wamp whenever I change .htaccess. Also if I write asdf at the top it does give a 500 Internal Server Error so I know the file is being read.

What am I doing wrong?

Here is the .htaccess file located in a couple sub directories (www/demos/test/):

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  # Adaptive-Images -----------------------------------------------------------------------------------

  # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
  # RewriteCond %{REQUEST_URI} !ignore-this-directory
  # RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too

  RewriteCond %{REQUEST_URI} !assets

  # don't apply the AI behaviour to images inside AI's cache folder:
  RewriteCond %{REQUEST_URI} !ai-cache

  # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
  # to adaptive-images.php so we can select appropriately sized versions

  RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php

  # END Adaptive-Images -------------------------------------------------------------------------------
</IfModule>

Here is my httpd.conf section:

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "c:/wamp/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options None

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    Allow from ::1:

</Directory>
MLM
  • 3,660
  • 3
  • 41
  • 66

1 Answers1

1

Alright, I figured out why it was not working! This was not a WAMP/localhost problem at all.

For some reason the default .htacess file that adaptive images comes with does not work out of the box for every situation. But... All I had to add was [NC,L] to the end of the rewrite rule. The html and image tag has the .jpg extension as lower case but my image file was written in caps (.JPG) which I did not notice until I turned on file extensions in the file browser.

  • nocase|NC: Makes the pattern comparison case-insensitive.
  • last|L: Stop the rewriting process immediately and don't apply any more rules. Especially note caveats for per-directory and .htaccess context (see also the END flag).

Source

Here is the final code:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  # Adaptive-Images -----------------------------------------------------------------------------------

  # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
  # RewriteCond %{REQUEST_URI} !ignore-this-directory
  # RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too

  RewriteCond %{REQUEST_URI} !assets

  # don't apply the AI behaviour to images inside AI's cache folder:
  RewriteCond %{REQUEST_URI} !ai-cache

  # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
  # to adaptive-images.php so we can select appropriately sized versions

  RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php [NC,L]

  # END Adaptive-Images -------------------------------------------------------------------------------
</IfModule>
MLM
  • 3,660
  • 3
  • 41
  • 66