I have image.html and I want It to be shown in browser as image.jpg, because there are some operations when showing picture, that can't be done before or after. Is it even possible with .htaccess and url rewriting?
I tried
RewriteEngine On
RewriteBase /
RewriteRule ^image\.html$ image.jpg
but without any luck.
Thanks for all answers
First of all, you'll need let's say a PHP script. Call it image.php
. After that, use a GET parameter to handle the image name. Let's call it name
. To call a picture you need image.php?name=allo
.
Now. In the PHP script, you need to specify in the header it's an image, JPEG. Required. After that, just "print" the picture within the page.
All you need after is Rewrite rule.
RewriteEngine On
RewriteBase /
RewriteRule ^image\.php?name=(.*)$ /images_jpeg/$1
The header is really important. This is why it doesn't work with an HTML file.