How can I set codeigniter to route this:
/download/folder/file.ext
to this
/download?path=folder/file.ext
?
I know how to do it using .htaccess , but is it possible in CI only? I tried
$route['download/(:any)'] = "download/index/?path=$1";
didn't work ... thanks
I urge you to change your perspective of what the CI Router class does (this was the most difficult thing for me in moving from the "rewriting" approach to the "router" approach).
Your question assumes a "rewriting" approach, and here's how it could be handled with an .htaccess file:
Under this approach, you'll have a route to match just the "/download" part, and then you'll use
$this->input->get('path')
in the controller action.The "routing" approach keeps the .htaccess file the same, and changes your $routes configuration, as well as how the controller "gets" that information, if you will:
This is the approach, so adjust as needed for your specific requirements.
Cheers!