Skip to header Skip to main navigation Skip to main content Skip to footer
  • Log in
Home
DrupalVIP
Freelancer service with great care and enthusiasm.
  • Home
  • Products
  • Blog
  • Support
    • Dictionary
    • Drupal Resources
    • External Resources

How to do a RedirectResponse with a destination query parameter

Breadcrumb

  • Home
  • DrupalVIP Support
  • How to do a RedirectResponse with a destination query parameter

How to do a RedirectResponse with a destination query parameter

 

Drupal 8 and on, is well integrated with Symfony technology and object 

good example is the Response with a redirect

use Symfony\Component\HttpFoundation\RedirectResponse;

$target = 65; // a parameter you want to add
$url = Url::fromUri('internal:/node/add/page'); // choose a path
$link_options = array(
  'attributes' => array(
     'class' => array(
        'btn',
     ),
   ),
   'query' => array(
     'target' => $target
   )
);
$url->setOptions($link_options);
$destination = $url->toString();

$response = new RedirectResponse($destination);
$response->send();

 

$redirectURL = '/cart/add/p2';
return new RedirectResponse(base_path().$redirectURL);

you can also use Drupal HttpFoundation library

object: SecuredRedirectResponse

Provides a standard base class for safe redirects.

In case you want to redirect to external URLs use TrustedRedirectResponse.

For local URLs, we use LocalRedirectResponse which opts out of external redirects.

Code Snippet
Read More
abstract class SecuredRedirectResponse
The HttpFoundation Component
Tags
Symfony
response
Redirect
Code Example
route programming
Drupal 9

The Freelancer Assistance

Proactive Maintenance

Proactive Maintenance

Drupal Shared Space

Drupal Shared Space

Site Management

Site Management

Drupal Training

drupal training session

Drupal Development

Drupal Development

Fullstack Service

Fullstack Service
Review All Services

Buy Hourly Support

 

Drupal platform support for complex websites. The service includes support, training, troubleshooting, fixes, updates, tool creation and module building.
* Minimum order is for 5 hours of support
* For every 20 hours of order you will be entitled to an additional hour of support
* For every 50 hours of order you will be entitled to 5 additional hours of support

 

>> Payment <<

 
cards

מופעל על-ידי paypal

Legal

  • Home
  • Contact
  • Products

Footer menu

  • Home
  • Contact
  • Products

Copyright © 2026 DrupalVIP project of Automatic Frameworks - All rights reserved

Developed and Maintain by Jonathan Ben Hur Freelancer