Welcome Guest, Not a member yet? Register   Sign In
Adding an extension to the filname on one controller
#1

[eluser]Mat-Moo[/eluser]
I need to create a routine xxx/feed.txt for another application to read. I've created xxx/feed which is perfect, but how can I get the controller to respond to the .txt request?
#2

[eluser]Aken[/eluser]
You can set up a route to redirect the URL w/ extension to the controller itself. Easy as pie.

Code:
$route['xxx/feed.txt'] = 'xxx/feed';
#3

[eluser]Mat-Moo[/eluser]
Thanks, I'll give it a whirl!
#4

[eluser]nicholas.byfleet[/eluser]
I wonder if this can also be achieved through using server redirects (.htaccess)?
#5

[eluser]Aken[/eluser]
Sure it can. I'd prefer doing it with CodeIgniter's routes, though. Then all my URL modifications are in one place in case there's an issue.

Edit: Just saw you said redirects. You don't want to use a redirect in this situation, because it will actually force a page reload to the new URL. If you were to use .htaccess you'd want to set up a ModRewrite rule, not a redirect.




Theme © iAndrew 2016 - Forum software by © MyBB