CodeIgniter Forums
Trying to put a file in controller or view but have it render as a fully pathed URL? - 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: Trying to put a file in controller or view but have it render as a fully pathed URL? (/showthread.php?tid=11885)



Trying to put a file in controller or view but have it render as a fully pathed URL? - El Forum - 09-26-2008

[eluser]electromute[/eluser]
I am working on a Facebook connect integration with CodeIgniter. I have everything working, but just not exactly the way I want it.

Here's the problem:

I want my callback URL in my Facebook Connect app to be http://mydomain.com/callbackdir/

The facebook connect relies on a file called xc_receiver.htm to deal with cross-domain authentication issues. Because of the way things are configured, Facebook wants to see this file at:

http://mydomain.com/callbackdir/xd_receiver.htm

I have my controllers set up with home.php as the default and divided into subdirectories for cleanliness like so:

--controllers
--home.php
-----callbackdir
-----home.php
-----anotherdir
-----home.php


Is there any way for me to put my xd_receiver.htm file somewhere and have it look like it's under the directory of my controller, callbackdir?

I have everything working fine if I leave FB connect stuff at root. I can leave it there if this is not possible, I just would rather organize things as noted above. Thanks!


Trying to put a file in controller or view but have it render as a fully pathed URL? - El Forum - 09-26-2008

[eluser]onejaguar[/eluser]
I know squat about Facebook apps but it sounds like you can do a rewrite in your .htaccess file; e.g.:

Code:
RewriteEngine on
RewriteRule ^callbackdir/xd_receiver.htm$ /home.php/callbackdir/xd_reveiver [L]



Trying to put a file in controller or view but have it render as a fully pathed URL? - El Forum - 09-28-2008

[eluser]electromute[/eluser]
Ah, of course! That is a very simple solution. So, here's what it looks like:

In my .htaccess file, I have:

Code:
RewriteEngine on
RewriteRule ^fbconnect/xd_receiver.htm$ /fbconnect/home/xd_receiver [L]

In my fbconnect/home.php controller, I have:
Code:
function xd_receiver(){
        $this->load->view('fbconnect/xd_receiver.htm');
    }

So far, so good. Thanks for your help!