Welcome Guest, Not a member yet? Register   Sign In
Showstopping issue (routing)
#1

[eluser]Sector[/eluser]
Hello there. I'm refactoring a huge site into CodeIgniter, and all has been going
well (albeit a little slow) except for this one thing I can't seem to get fixed.

In the site is a piece of flash that displays an agenda. This flash app searches for its
data in a hardcoded path: data/data.xml

This was fine on the old site: http://xxx/data/data.xml

But CodeIgniters routing seems to turn this into http://xxx/index.php/data/data.xml

Not only have I already used Data to make one of my libraries (so I cannot create a controller named Data as well, apparently). But it is impossible to create a function named something like:

Code:
function data.xml() {
   ...
}

So I cannot even emulate this URL.

Any help would be much appreciated!
#2

[eluser]coolfactor[/eluser]
You can use a custom route to redirect the request to a different controller/method.

In config/routes.php:
Code:
$route['data/data.xml']  = 'name_of_controller/name_of_method';
#3

[eluser]kucerar[/eluser]
Put in an ignore clause just before the rewrite rule in the httpd.conf.

I did it in order to serve some txt files, had enough of a pattern to scrape together an ignore that worked. Something like '*scan.txt'.

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|*something.xml)
RewriteRule ^(.*)$ /index.php/$1 [L]

Just *.xml may work.

HTH,
-R
#4

[eluser]Sector[/eluser]
Thanks for the input kucerar, but I prefer to not configure Apache because I probably won't have control over that.

Coolfactor: that solution worked wonderfully, and it's remarkably elegant too. Thanks a lot!




Theme © iAndrew 2016 - Forum software by © MyBB