Welcome Guest, Not a member yet? Register   Sign In
Problem with passing a URL as a variable to a controller

I have searched all over for the answer to this but have only found about a thousand "how do I pass a variable in the url" type questions Smile

I am using jquery to grab a url from a form field and would like to be able to send it to a controller. I thought that using encodeURIComponent on the url before trying to pass it would work but I still get a 404 error.

It ends up looking like:

http://domain.com/controller/method/http% 3A % 2F % 2Fwww.url.com
which gives a 404, although
doesn't. I added the spaces in the encoded url because I couldn't get it to stay encoded for the purposes of this post.

Is there something I can do to the url to allow it to be passed as a parameter to the controller?

Thanks in advance for any help!

If you are able to pass in the "www.url.com" without the "http..." etc then it will work.
You can add the "http..." to the variable from within the controller if you really need it.

Hope that helps

So your grabbing your url from a hidden form field as text eh...? To be honest I cannot see a single reason you cannot or should not be able to just pass it through to your controller and do whatever you want with it... You shouldn't need to encode it or anything else before sending it - just pass it straight through to your controller as you would any other form field value and manipulate it (if you need to) inside the controller.

If you cannot get the hidden form url field passed, as plain text, to your controller try posting some code on here.

It is an input field where you can enter a url to a blog. It then uses Ajax to grab what the user entered and pass that url to a controller, which attempts to detect the feed url for that blog, and fill out the "feed url" input field for the user.

Ayeyermaw is right, it will let me pass "www.site.com" as a variable.


There is something about the http:// that it doesn't like, even when it is urlencoded.

I think that it's because the "http://" triggers a reaction from the browser so the browser sees it and tries to act upon it.
It would probably work if you sent it to the controller via the POST method rather than a GET (although I haven't tried it).

Apache is preventing encoding slashes from being processed.


Theme © iAndrew 2016 - Forum software by © MyBB