-1

we have to move one of our web projects but have (printed) urls/QR Codes in the market, that currently would fail.

Example: QR Code resolves to http://www.domain1.com/?/12345

We would like to forward this url to our new server with the help of .htaccess on domain1.com - the forward should go to: https://www.domain2.com/?/12345

We cannot just forward ALL requests, as ONLY the /?/xxxx content has been moved ...

We know the /?/ has not been the best choice, but those codes cannot be modified right now any more :(

Christian K.
  • 528
  • 6
  • 16

1 Answers1

0

You must first check the query string for the appropriate pattern, and if the request is for the root. Then redirect to the new domain

RewriteCond %{QUERY_STRING} ^/\d+$
RewriteRule ^$ https://www.domain2.com/?%{QUERY_STRING} [R,L]

To check for a slash, followed by anything is the same as checking for just a slash, e.g.

RewriteCond %{QUERY_STRING} ^/

When everything works as it should, you may replace R with R=301 (permanent redirect). Never test with R=301.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • unfortunately, there is NO possibility to check against the query string. Only "common" is the /?/ between the domain-name and the variable. Is there a way to check for /?/ ? – Christian K. Apr 22 '17 at 11:46
  • The first slash is part of the request path, the second slash is part of the query string. – Olaf Dietsche Apr 22 '17 at 11:59