1
votes

There is a strange problem in my Laravel routing. When I use this url everything goes perfect:

Route::get('properties/{product}', 'ProController@getpro');

But while I want to change the order like below, I get a 404 not found page:

Route::get('{product}/properties', 'ProController@getpro');

What is the problem?

http://127.0.0.1:8000/product/pizza-lake-dariusbury/properties 404 (Not Found)

I'm using Laravel installer version 2.0.1

1
There is no laravel 2.0.1 version - Ayaz Ali Shah
@AyazShah laravel installer version i mean - Masume Ebhami
Do you have another ProController routes declared? - Laerte
@Laerte yes i have another one that take two parameter just :: Route::get('{prod?}/{prod_size?}', 'ProController@name') - Masume Ebhami
@Laerte alles ok - Masume Ebhami

1 Answers

2
votes

Since you are using two routes that take generic parameters, Laravel could have problem to match a URL to a route. For example: /product/1/properties, could perfectly fit this {prod?}/{prod_size?}.

To fix this, I suggest that you add some prefix to the route, to identify them:

Route::get('routename1/{product}/properties', 'ProController@getpro');
Route::get('routename2/{prod?}/{prod_size?}', 'ProController@name');

Then routename1/1/properties would never fit routename2/{prod?}/{prod_size?}.

Then Laravel would be able to match perfectly the URL parameters to the route.