Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 2 years ago.
0

Does anyone have the answer please :)

0

You will need to use .htaccess to change the legacy URL to a Laravel-friendly one.

0

I was afraid that was the answer. :(

0

Actually, you can make this work. You can't put query params in the route string, but you can use Input (which is just a facade for Request) to get them.

Route::get('products.php', function() {
  if (Input::has('pid')) {
    echo 'New Product ID: ' . Input::get('pid');
  }
});
0

Hmmm.. Hamstu I put that code in my routes.php file and nothing outputs. I put an echo before the if and the echo appears but it doesn't appear to have access to any of the input vars inside the route file. Is there something special to do to make that happen?

I also tested this code which works but when i change products to products.php it finds the route but the echo of the input variables ends up blank no pid or variable. Its like its not reading the input variables when the route has a .php on it. Any ideas how to get past this other than using .htaccess file?

Route::get('products', function() {
    echo Input::get('pid') . ' -' . Input::get('c');
});

hamstu said:

Actually, you can make this work. You can't put query params in the route string, but you can use Input (which is just a facade for Request) to get them.

Route::get('products.php', function() {
 if (Input::has('pid')) {
   echo 'New Product ID: ' . Input::get('pid');
 }
});
Last updated 9 years ago.
0

Furthermore, stop doing all that stuff in your routes, rather route to your controller/method and get the
querystring string vars the right way..............

$ mynewvar = Input::get('whatever'); //from querystring

products.php?pid=x&flag=x

$ mypid = Input::get('pid');

etc, etc, etc.

0

And htaccess does not need to be messed with or messed up at all.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.