• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
passing a url in the url

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)...
<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

Try base64 encoding.

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?

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).

Why not use an id instead of the url?

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.

[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]

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.