Welcome Guest, Not a member yet? Register   Sign In
passing a url in the url
#1

[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
#2

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

[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?
#4

[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).
#5

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

[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.
#7

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




Theme © iAndrew 2016 - Forum software by © MyBB