2

I want ANY image in any folder in my magento website could be able to get accessed both with its actual file name OR a .MAIN extension at the end of the file.

As an example, In case I have an image like:

http://www.whatever.com/media/catalog/product/cache/1/small_image/218x330/9df78eab33525d08d6e5fb8d27136e95/i/p/whatever-name.jpg

I want it to get access with both follwoing URLs:

  1. http://www.whatever.com/media/catalog/product/cache/1/small_image/218x330/9df78eab33525d08d6e5fb8d27136e95/i/p/whatever-name.jpg
  2. http://www.whatever.com/media/catalog/product/cache/1/small_image/218x330/9df78eab33525d08d6e5fb8d27136e95/i/p/whatever-name.jpg.MAIN

I tried to adding some URL rewrite rules under /media/.htaccess but no luck at all:

RewriteRule ^(.*)(\.MAIN)$ $1

So my .htaccess file is look like this:

Options All -Indexes
<IfModule mod_php5.c>
php_flag engine 0
</IfModule>

AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI

<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on


############################################
## never rewrite for existing files
    RewriteCond %{REQUEST_FILENAME} !-f

############################################
## rewrite everything else to index.php
    RewriteRule ^(.*)(\.MAIN)$ $1
    RewriteRule .* ../get.php [L]
</IfModule>

Actually NO rule working in this media .htaccess file. I tried many different other dummy rules for other purposes non of them even working.

How can I accomplish this ?

1

Try put your RewriteRule ^(.*)(\.MAIN)$ $1 above RewriteCond %{REQUEST_FILENAME} !-f because that rewrite condition means if file is not exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.