CodeIgniter Forums

Full Version: passing a url in the url
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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"">

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

El Forum

Try base64 encoding.

El Forum

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?

El Forum

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

El Forum

Why not use an id instead of the url?

El Forum

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.

El Forum

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