I have a client whose company has different branches. The data are retrieved from a DB (not the Drupal one). For example, the url mydrupalsite.com/branch?branchID=1 should lead to mydrupalsite.com/branch/1, mydrupalsite.com/branch?branchID=23 to mydrupalsite.com/branch/23. I have created a page for the branches, at which the content will change slightly and dynamically, according to the branch we choose. I've tried using InboundPathProcessorInterface(), OutboundPathProcessorInterface() and PathProcessorAlias(), but I can't get rid of the query ?branchID=23, so I only get mydrupalsite.com/branch/23?branchID=23.

Is there any way to achieve that?

  • Welcome to Drupal Answers! We love to help you. This sounds more like a server-side redirect issue. From .htaccess. Maybe you can elaborate a bit how these pages are built and how they pull their content exactly.
    – leymannx
    Oct 23, 2018 at 8:58
  • Thank you for your answer! We have built a custom Page (/branch) and we want to access that specific page and change its contents, according to the DB data through a menu callback. So, basically, the only things that will be changing are the path and the title. So, I am required to rewrite every URL of this form (mydrupalsite.com/branch?branchID=1) to mydrupalsite.com/branch/$1, and all of them should lead to /branch page.
    – S.P.S.
    Oct 23, 2018 at 9:38

1 Answer 1


I think you can use Redirection Rules in your .htaccess file to achieve this task.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_URI} ^(/branch)$
  RewriteCond %{QUERY_STRING} branchID=(.*)
  RewriteRule (.*) /branch/%1?  [R=301,L]

Hope, this helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.