Laravel 4.2 Redirect :: to with GET Params

Is there a possibility to redirect to an url with GET params using Redirect::to() in Laravel 4.2?

I'm trying to redirect users after login to requested page when they weren't logged in.

If you are not logged in and you visit authorized page, I save the full requested url in session (this url can be something like https://page.com/settings or https://page.com/post/23 or https://page.com/post/23?show=full. Lots of variants).

When you then log in and you have an url stored in your session, I redirect you with Redirect::to(https://page.com/post/23)

In first two cases there is no problem, but when I use Redirect::to(https://page.com/post/23?show=full) GET params are ignored.

Is there an option to redirect to url with GET params included?

Try this:

You can pass it like https://page.com/post/23/showFull

And you can got it via following way:

Request::segment(3);

There's problem with your application. If I understand you correctly, your query parameters (such as: ?param=true&param2=1) are not present in your url after redirect.

Consider the following example:

Route::get('/test', function () {
    return Redirect::to('http://localhost:8000/test2?with=params');
});

Route::get('/test2', function () {
    echo '1';
});

When I try to access: localhost:8000/test I get redirected to: http://localhost:8000/test2?with=params

Which is the expected behavior. Can you post an example where you do that redirect?

Also I'd suggest using: Redirect::intended() which does exactly what you want by itself.

Why not Redirect::back()? The auth filter should be able to redirect all the non-authed requests to the login page, then Redirect::back() the user to the previous visited page.

Edit: filter, not middleware.

In Laravel, By default this feature is available if you are using the auth middleware, as given below:

Route::group(array('before' => 'auth'), function(){

//authorized routes

});

Example

If the user without loging in, is accessing the url "example.com/User?abc=123", which is an authorized route.

Then the user will be redirected automatically to the login page.

After successful login the user will be automatically redirected to the url first requested ("example.com/User?abc=123")