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

randy_roberts's avatar

How to remove parameters from url

I have developed a connector that will allow me to page by page transition a large legacy php application to Laravel 5. To accomplish that I needed to pass some session data to Laravel. I could not find or figure out how to do that. So I am using a table to send the user credentials with a random lookup id which I pass as a parameter to Laravel. Works well but I would like to remove the id from the target route once I have used it.

0 likes
5 replies
JeroenVanOort's avatar

I guess nobody has replied to your message yet because they don't understand what you're trying to do. I don't either.

What do you mean by 'page by page transition'? Do you read the database, do you scrape all pages?

I guess your message is clear to you, but it isn't to someone not knowing the background of what you're trying to accomplish. Please enlighten us.

randy_roberts's avatar

That is not really relevant to the URL removal q, but i will explain the migration task I need to do. The current app is very large, 80K lines of code, over 100 tables and 6 companies running on separate domains and db's. 2 dir levels,1st for front end and 2nd for admin (backend). I have been testing various frameworks for the last year and each of the best are hard to have running alongside an old PHP 5.3 app. I could not get Laravel to run the admin level ( placed the site in public). It would login, but than just come back to login again.

So I moved the old app back up to the root to see if I could change one link at time to somehow route to Laravel. But that too was problematic and getting at the session was a no go. So I thought why not create a sub domain for Laravel under the old sites... oldsite.com and oldsite.com.2 Now I could link via the 2nd site and routing works. But, no session data no matter what I tried.

So I decided to roll my own. This actually was something I thought of quite a while ago. So I created a very small driver program which is used for any converted link. 2a.php?routename gives the name of the route to the driver. Now to get the session data I need, the driver inserts a record into the utickets table with the data laravel will need to determine which user's info is to be pulled. To tell Laravel what ticket it is I pass a random # in very large range and Laravel finds that with the route+number. Once found the ticket is set inactive.

So in the Laravel routing when it sends the request to the browser I have the number there as a parameter.

My question is how do I remove that in the routing process as it is not needed?

jlrdw's avatar

A regular query string doesn't need any extra parameters in the route if its a get route. Just pass in the URL. Then in the controller use laravels request methods to get your data.

azimidev's avatar

Didn't have time to read your whole question but this is your title respond:

create a link like this and this will clear all parameters:

<a href="{{ request()->url() }}">Clear Parameters</a>
1 like
ArashYounesi's avatar

Laravel 7:

You can remove specific parameter(s) from url by passing null to fullUrlWithQuery function like below:

request()->fullUrlWithQuery(['specific_parameter' => null])

Please or to participate in this conversation.