Search code examples
urlencodelaravelurl-encodinglaravel-3

Is there any reason why a urlencoded string would throw a 404 error?


I'm trying to pass two parameters, one of which is an email address.

routes (also tried (:any))

Route::any(
    'user/confirm_request/(:any?)/(:any?)', array(
                                             'uses' => 'user@confirm_request'));

controller (also tried post_confirm_request())

public function get_confirm_request($email, $term)
{ 
  //do stuff
}

Ultimately, all I'm trying to do is hit that route and send an email to a user with those two parameters. But I keep getting a 404 error. The email gets encoded and the route looks like this:

/email%40gmail.com/someString

I'm able to take out %40 and it works just fine (just gives me an error for the sendmail). Why would the %40 be throwing a 404 error? Could it be a Laravel thing?


Solution

  • One solution would be to pass the email as a url parameter.

    First, remove the second argument from the route. (You could also remove both if needed.)

      Route::any('user/confirm_request/(:any?)', array('uses' => 'user@confirm_request'));
    

    Then append the email to the action url, something like this..

      $url = URL::base() . '/user/confirm_request?email=' . $email;
    

    Then in your controller, you can grab that data.

      public function get_confirm_request()
      { 
        $email = Input::get('email');
      }