CodeIgniter Forums
passing a url in the url - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: passing a url in the url (/thread-9199.html)



passing a url in the url - El Forum - 06-16-2008

[eluser]deadelvis[/eluser]
Hi
I'm trying to write a generic redirect function on my main controller. What is the best way to pass a url in the url?

Generating links with format (url encoded url)...
Code:
<a href"http://mysite.com/redirect/http(%)3A(%)2F(%)2Fothersite.com(%)2Fsomepage.php">


... leads to "Page not found" error, due to the (%)2F in the string being interpreted as /.

Any ideas on how to do this easily?

PS: Percentage sign % substituted by (%) for display reasons


passing a url in the url - El Forum - 06-16-2008

[eluser]mglinski[/eluser]
Try base64 encoding.
base64_encode(data)
base54_decode(data)
-Matt


passing a url in the url - El Forum - 10-06-2008

[eluser]jwright[/eluser]
I'm having the same issue. I don't really understand XtraFile's response.

But also, I will be generating this type of url from javascript and elsewhere (rather than from with the CodeIgniter app). It would be very convenient to be able to encoded my urls with the standard url encoding...

Can anyone help with fixing the above problem?


passing a url in the url - El Forum - 10-06-2008

[eluser]jwright[/eluser]
I was able to solve my problem by url encoding the url twice and then passing it to the controller...

like this ...

http://localhost/myapp/index.php/controller/index/[url encoded twice]

then... CodeIgniter decodes it once automatically (this is why it wasn't working before)... then in your controller your parameter is in url encodeded form (once).


passing a url in the url - El Forum - 10-07-2008

[eluser]xwero[/eluser]
Why not use an id instead of the url?


passing a url in the url - El Forum - 10-07-2008

[eluser]jwright[/eluser]
In this case I'll be preparing links from outsite the application. I could come up with another more complicated approach involving ids or encrypted urls but this is simpler and much more convenient.


passing a url in the url - El Forum - 10-07-2008

[eluser]Nick Husher[/eluser]
You could switch to using query strings instead of CI segments, that might get you a bit farther:

mysite.com/?c=redirect&amp;url=[some url]