CodeIgniter Forums
Redirect image.gif to controller/function/image - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Redirect image.gif to controller/function/image (/showthread.php?tid=41882)



Redirect image.gif to controller/function/image - El Forum - 05-19-2011

[eluser]DrDave[/eluser]
Hello,

I am working on dynamically generated images. I'm trying to have the url http://domain.com/rankimg/123.gif redirected to http://domain.com/index.php/rank/image/123 so that whatever the image is called, the name will be passed as a variable to the image function of the rank controller.

This is my .htaccess:

Code:
RewriteEngine On
RewriteRule ^rankimg\/([0-9]+)\.gif$ /index.php/rank/image/$ [L]

Using this, I get a 404 error, however going to http://domain.com/index.php/rank/image/123 produces the image. Any ideas what I am doing wrong?

Thanks in advance!


Redirect image.gif to controller/function/image - El Forum - 05-19-2011

[eluser]DrDave[/eluser]
I figured out how to do it using URI routing. I added this line to config/routes.php

Code:
$route['rankimg/(:num).gif'] = "rank/image/$1";