![]() |
Rerouted route and output headers - 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: Rerouted route and output headers (/showthread.php?tid=52843) |
Rerouted route and output headers - El Forum - 06-28-2012 [eluser]Unknown[/eluser] I swear this was working a few hours ago but now it's not I have an old website where people can download levels for an old video game. They would normally go to the url http://mydomain.com/maps/filename.zip I've since re done the site in codeigniter the correct url now is http://mydomain.com/downloads/maps/filename.zip However, in case they use outdated links I added an override in my routes Code: $route['maps/(:any)'] = "downloads/maps/$1"; What im trying to do is store the file into a variable, do some logging in the database and then send the file to the output buffer so that it downloads it Everything works fine when i access the route directly by going to http://mydomain.com/downloads/maps/filename.zip But when i access the alias (mydomain.com/maps/filename.zip) it still goes into the correct controller and method but chokes on the output part. For instance i can debug with var_dumps and it works all day but when i try to output the file i get errors Chrome: Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found. IE: Asks to open or save then says the file cannot be opened/saved FF: Firefox cannot find the file My downloads function looks like this Code: function maps($filename=null) Rerouted route and output headers - El Forum - 06-28-2012 [eluser]Unknown[/eluser] I'm now getting around it by setting up a controller called maps and putting redirect logic in the constructor Code: class Maps extends CI_Controller If anyone knows how I can do it the way I want in the post above then please let me know Thanks |