How To Redirect A Link

Table of contents:

How To Redirect A Link
How To Redirect A Link

Video: How To Redirect A Link

Video: How To Redirect A Link
Video: How To Redirect a URL in WordPress 2023, December

The essence of the redirect boils down to the fact that the transition to an external link is made through a script located inside the site. As a result, the user goes to an external resource, and the search robot remains inside the site during the indexing process. The redirect script can be written in different ways. The given example should be considered as valid, but not the only true one.

How to redirect a link
How to redirect a link

It is necessary

Access to the file system of the site, the simplest text editor, for example, "Notepad"


Step 1

On your local computer, open Notepad and write the following PHP script: $ urlsite = $ _GET ['urlsite']; if (! Empty ($ urlsite)) {$ urlsite = str_replace ("http:", ", $ urlsite); $ urlsite = "http:". $ urlsite; header ("location: $ urlsite");} This script gets the urlsite parameter via the GET method and checks if it is empty. Then it removes https://, if present, leaving only the portion of the URL that does not contain the protocol type. Then re-sticks https://. This eliminates the possibility of duplicating the protocol pointer required for correct redirection. The last line of the script tells the browser the address to connect.

Step 2

Save the created file as redir.php. In the "Notepad" menu, select "File", then "Save As". In the file type section of the save window, specify "all types", and write the file name in full with the extension.

Step 3

Upload the generated script file to the root directory of your site through your control panel. Find the "File Manager" menu, go to the site folder and click the "Download" button. Find the script on your computer and click the "Upload" button. The redir.php file will appear in the root directory of the site.

Step 4

Write down the prohibition on indexing for search robots in the robot.txt file: user-agent: * Disallow: /redir.php The search engine robot will ignore this script.

Step 5

Add a link of the form Urlsite = in the desired place on the site. If it is necessary to send the “&” sign to the address, replace it with “% 26”, the space with “% 20”, “@” with “% 40”. Now the link is internal, but through the script it leads to an external resource. The search robot will ignore it and continue indexing the site. The so-called "puzomerki", TCI and PR, will not be transmitted.