Any way to reroute a path to a file on the webserver either with Fuel or Codeigniter?

edited February 2012 in Share
I have a need to redirect users from an old path location for an XML file to a new path location. The old location is /stations/bikeStations.xml and the new path is /data/stations/bikeStations.xml.

I've tried adding this custom route in the routes file, but it doesn't appear to work:

$route['stations/bikeStations.xml'] = 'data/stations/bikeStations.xml';

I also have a stations controller, in which I inserted the following code to check the 2nd URI segment to try and redirect them to the new location that way:

if($this->uri->segment(2) == 'bikeStations.xml') { redirect('data/stations/bikeStations.xml'); }

Why wouldn't this work? I understand it is a Codeigniter thing, but I'm wondering why file references are not supported with the URI routing class in Codeigniter. Perhaps Fuel has something that can work in this case?

Thanks,
Erik

Comments

  • edited 4:29AM
    The end goal is to download it? The second might work if you use force_download(path/to/file) instead of redirect
  • edited 4:29AM
    Yes, the end goal is to download it. I figured out how to do it by adding a redirect command in the root .htaccess file. That handled it pretty well, thanks!
Sign In or Register to comment.