CodeIgniter Forums
Pass variable with slashes in URI without it being interpreted as another segment - 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: Pass variable with slashes in URI without it being interpreted as another segment (/showthread.php?tid=33622)



Pass variable with slashes in URI without it being interpreted as another segment - El Forum - 09-02-2010

[eluser]Unknown[/eluser]
I'm creating an image hosting site, I'm using mod_rewrite to intercept all incoming requests to the root folder where images are stored - /i/ - and silently redirecting it to a CI controller that will record various things about the image being accessed and then set the required header type and output the image.

I've got it working at the moment using a separate php file and using mod_rewrite to pass the requested image as a GET variable i.e RewriteRule (i/.*) access.php?i=$1 [L]

But now I want to point it to my CI controller http://localhost/images/access/IMAGE_PATH which would be done like: RewriteRule (i/.*) images/access/?i=$1 [L]

However the GET parameter never makes it, and if I try images/access/$1 then CI interprets the slashes in the image path as segments and I can't access the entire path using $this->uri->segment(3);

Is there a way around this and if so what is the "correct" way of doing so? Any help is appreciated.


Pass variable with slashes in URI without it being interpreted as another segment - El Forum - 09-02-2010

[eluser]Unknown[/eluser]
I've worked around this by enabling GET variables as per http://ellislab.com/forums/viewreply/277621/

And updated my mod_rewrite rule to: RewriteRule (i/.*) images/access/?i=$1 [L]

I'm going to push on ahead now but I'm still very interested if there's a more correct way of doing this thanks Smile