When using a QR code for commercial purposes, sometimes a situation arises that after the wide distribution of the QR code, it becomes necessary to change some data - the phone number, or the address of the page that should open after scanning the code.
Recently I have received several requests with questions about this.
We generated a code for sending a message to WhatsApp, distributed the code in public places, then it turned out that some data needed to be clarified - the phone number where the message would be sent or the text of the message itself.
The only way out in this situation is to create and distribute new code with the correct data.
Must be foreseen in advance
In order not to find yourself in such a situation, in cases where there is a possibility that in the future you will need to change the result of scanning a QR code, it is recommended to use an intermediate address from which redirection will be performed to the desired final address with the necessary parameters, or, if desired, you can display changeable data directly on this intermediate page.
For this, you can use special services for creating QR codes that provide such a service. In this case, when scanning the code, the user is first directed to a permanent page on the site of such a service, and then redirected from it in the direction you need. The original address does not change, but the redirection direction can be changed at any time.
This can be organized independently without being tied to extraneous resources.
Step-by-step instruction
Here it will be described step by step - how to create such an intermediate page and perform redirection on your own, without relying on third-party services.To do this, you will need to register a domain, rent hosting. In fact, you are creating a website, but it will consist of only one file and perform only one function - to perform an instant and imperceptible redirect to the desired address.
1. Register a domain.
A domain is the name of any site and its address, which is visible in the address bar. You can register a domain with any registrar that provides this service. The instructions will contain a description on the example of the registrar and hosting ExclusiveHosting, the services of which I myself currently use.
Go ExclusiveHosting website, create an account. Open the menu item: My Domains - Registered Domains - Register / Transfer Domain.
Choose a domain name from the available ones by entering options in a special field, register a domain. Specify that you want the domain to be associated with your hosting account. Wait a few hours until the domain starts working and when you enter its address in the address bar of the browser, a page will open with the text that the domain has been registered or the site has been created.
2. Order hosting.
Immediately after registering using the link above, you will be given a free trial month of hosting on this service. You can immediately pay for hosting for a year in advance. If after the end of the free month you do not renew your hosting services, your domain will still be yours, but the files mentioned below will stop working. Hosting services are services for storing your files.
3. Enable SSL certificate.
This is necessary so that when people go to your site, people do not receive alarm notifications that the connection is insecure, sometimes browsers block transitions to sites without an SSL certificate.
In the menu, select the items: My Domains -> SSL Certificates.
The options are either to Order SSL certificate or Request Let's Encrypt certificate.
You can activate a free Let's Encrypt certificate, just select this option, activate and wait an hour.
If you have just registered a domain and receive an error message including a certificate, please try again in a few hours.
4. Create a redirect script.
Now go to the file manager. Open the root folder of your site public_html.
Find the index.php file in this folder (if it doesn't exist, create it). Open this file for editing and paste the following code.
<?php
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://unila.ru");
}
?>
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://unila.ru");
}
?>
Instead of https://unila.ru, put a link to a page on a social network, a link to a video on a video hosting site, a Telegram profile, a Telegram chat, a WhatsApp chat - where a person should go after scanning your code.
For example, if you want the Twitter website to open after scanning your code, the code will look like this:
<?php
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://twitter.com");
}
?>
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://twitter.com");
}
?>
If you want a Telegram channel to open after scanning the code, the code will look like this (replace unilaru with the name of the desired channel):
<?php
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://t.me/unilaru");
}
?>
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://t.me/unilaru");
}
?>
If you want to open not a channel in Telegram, but a chat with you in Telegram, instead of the channel name, specify your username in Telegram in the code above.
If you want to open a chat with you on WhatsApp, the code will look like this:
<?php
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://wa.me/7XXXXXXXXXX");
}
?>
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://wa.me/7XXXXXXXXXX");
}
?>
Replace 7XXXXXXXXXX with your phone number in international format without the + symbol
If you want to open a WhatsApp chat with you and pre-set the message text, the code will look like this:
<?php
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://wa.me/7XXXXXXXXXX?text=".urlencode("Some text to send"));
}
?>
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '1'){
header("Location: https://wa.me/7XXXXXXXXXX?text=".urlencode("Some text to send"));
}
?>
Replace phone number and text of message
5. Creat QR code, which will contain only a link to your domain/website, and substitute characters at the end "?qr=1"
Example: https://unila.ru?qr=1
Anyone who scans your code will receive this link in response when they click on it, thanks to the actions that we performed in the previous steps in the previous steps, they will be instantly automatically directed in the right direction.
If one day you need to scan the same QR to redirect to a new address, or change the message text for WhatsApp, just go back to step 4 of this instruction and change the data in the index.php file.
If in the future you want to use the same site to process another QR code, use the link to your site again for the second QR, but set a different parameter at the end of the domain - "?qr=2"
And add the contents of the index.php file with new lines designed to process the second QR:
<?php
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '2'){
header("Location: https://t.me/unilaru");
}
?>
if(isset($_GET["qr"]) && trim($_GET["qr"]) == '2'){
header("Location: https://t.me/unilaru");
}
?>
Or, if you wish, you can arrange it so that when scanning the code, a page on your site opens (without redirecting anywhere) and on this page display some information, a block of links. I will not describe this point in detail, because this is another topic.