Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

avrahamm's avatar

Routing unfrieldly urls like /category.php?id=33

Hello! I try to route old style unfriendly url like /category.php?id=33 I wish to redirect it to /category/33 Yet Router doesn't catch it. The best I found is https://stackoverflow.com/questions/44367951/how-to-use-page-phpid-id-routes-on-laravel yet it didn't work for me.

Any idea will be appreciated!

0 likes
6 replies
MichalOravec's avatar

Does your catalog.show route exists?

When you remove redirect and show just id it works? It should

1 like
arfanon's avatar
arfanon
Best Answer
Level 1

using this "category.php?id=33" you are able to get the id with simple $GET["id"] then preform a simple search and redirect paste your code for more undrestanding .

here is a simple example

web.php

Route::get("test",function(){ dd($_GET["id"]); }); url : http://127.0.0.1:8000/test?id=5

1 like
avrahamm's avatar

Yes, catalog.show route exists and works, /category/33 works. I followed your advice and changed it to return $id; instead redirect and it worked. Then put it back to redirect, cleared cache:clear and it started to work.

Thank you very much!

Please or to participate in this conversation.