Using redirect_from while retaining original query string values

I am writing a multipage dash app which queries a database based on a set of query strings in the url.

Example1: webpage/querydie?lot=X&wfr=Y&die=z

I am going to use this app to replace the current database web interface which was written with .php

Example2: webpage/page/qr/query.php?lot=X&wfr=Y&die=z

Unfortunately the example2 url comes from qr codes on our substrates and would be a nightmare to change to the new url. I would like to use the “redirect_from” argument of the register_page method to redirect from example2 to example1.

What ends up happening is that I am redirected to the page but without the query strings.

Example3: webpage/querydie

Is there a way to carryover the query string from the example2 url? Or even capture the url variables before the redirect?

I have included some sample code to show the issue. In I tried a couple different methods to try and get it done (commented code) but none gave me the result I was looking for.

from dash import Dash, html, dcc
import dash

app = Dash(__name__, use_pages=True)

app.layout = html.Div([
	html.H1('Multi-page app with Dash Pages'),

                    f"{page['name']} - {page['path']}", href=page["relative_path"]
            for page in dash.page_registry.values()


if __name__ == '__main__':'localhost', debug=True, port=40)

import dash
from dash import html, dcc

dash.register_page(__name__, path='/')

layout = html.Div(children=[
   html.H1(children='This is our Home page'),

       This is our Home page content.


import dash
from dash import html, dcc

   # path_template="/archive?str1=<str1>&str2=<str2>",
   # redirect_from=["/archive-2020", "/archive?str1=<str1>&str2=<str2>"]

def layout(str1 = None, str2 = None, **other):
   return html.Div(children=[
           html.H1(children=f"This is our Archive page with {str1} and {str2}"),

               This is our Archive page content.


I ended up solving this using flask redirects.

My project is using an apache server run on XAMPP. I’m using mod_wsgi to host the dash app. In my .wsgi file I route the url with querystrings to the new url.

I wanted to go from this

to this

Implementing Dash on an apache server hosted through XAMPP was not trivial for me so if anyone has questions on that (which I know is kinda niche) please reach out.

Hope this helps someone.

import sys
from flask import redirect, request


from AppDashboard import server as application

def query_test():
    redir = '/newweb?' + request.query_string.decode()
    return redirect(redir)