SRL Archive - Web Development

rewriting uri to .png?


grats

2015-04-05 23:37:46

nginx / php

I want to have someone request example.com/folder/picture.png

that routes to picture.php which is creating an image

[PHP]<?php
$images = ['http://i.imgur.com/ykwcC.jpg','http://i.imgur.com/Urrl4.jpg'];
$i = rand(0,1);
header('Content-Type: image/jpeg');
readfile($images[$i]);
?>[/PHP]

^ for testing

I've tried like 50+ location scripts on stackoverflow etc for nginx, none working.. can't get anything working =/


of course the most familiar example to you guys would be http://www.draynor.net/signatures



nvm got it

literally opposite of what people were posting…….


location ~ ^/folder/img\.png$ {
rewrite ^/folder/img\.png$ /folder/img.php last;
}