How to check the url in the controller

You will need to change $request to the variable name you assigned the request object in the arguments of your controller. For example in your controller you might have named it $req, or something else entirely. Alternatively, can you post your controller so we can take a look?