SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face mod_rewrite to find images without extensions

    I recently moved a wordpress blog from a shared hosting to a dedicated server, because it was getting too big.
    On the previous server, images where automatically retrieved by apache even without .jpg .gif or .png in the url : apache would look for the closest file in the specified directory:
    <img src='http://www.myserver.com/wp-content/uploads/2012/02/image1'> would simply display the image1.jpg or image1.png or image1.gif, depending of which file was available (without showing in the URL though).

    Right now, all image references in the blog have been completed with their extension, thus resulting in no "internal errors", but all the images referenced on other websites give a 404 error (several thousands a day...).
    I've temporarily used wordpress redirect plugin to solve 80% of errors, but I'd rather find a more comprehensive solution, not to mention the significant impact on performance. I've also tried a simple .htaccess rewrite statement, but it works only for .jpg files, resulting in errors for any .png or .gif file:
    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^([^\.]+)$ $1.jpg [NC,L]
    </IfModule>


    I'd like to add a statement to a .htaccess file in my /wp-content/uploads/ directory that would enable this option to work again on any image file from the subfolders present in /wp-content/uploads/ .

    Any idea what it could be?
    Thanks a lot!

  2. #2
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, the answer was a bit simple ...

    .htaccess just needs to state:

    Options +MultiViews


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •