Looking for a better way to handle multiple link redirects?

I am wondering if there is a more efficient way of serving a large number of link redirects. For the background: my site receives tens of thousands of users per day, and we have a " deep link " to a large number of individual product pages on affiliate sites.

To "close" affiliate links and keep them all in one place, I currently serve all of our affiliate links from a single PHP file, for example. the user clicks on mysite.com/go.php?id=1 and goes to the page on the seller’s website, attached to our partner cookie, where you can buy the product. The code I use is as follows:

<?php

$path = array(
‘1′ =>  ‘http://affiliatelink1.com’,2′ =>  ‘http://affiliatelink2.com’,3′ =>  ‘http://affiliatelink3.com’,

);

if (array_key_exists($_GET['id'], $path))
header(‘Location: ‘ .$path[$_GET['id']]);
?>

, , , , php 11K + . , FTP , 2 , , . , php - , , , , .

, . .php (, go2.php), , go.php , . ? Wordpress, mySQL, PHP , , .

- , .. PHP , URL- , php , , 100K - .

? , , , ? , php, ? / !

+3
1

:

URL, SEO, , , "my_new_product/1"

mod_rewrite URL- , :

Rewriterule ^([a-zA-Z0-9_-]*)/([0-9]*)$ index.php?id=$2 [L]

, :

id (autonumber, ) url (URL ) (, URL- )

CRUD, .

+3

Source: https://habr.com/ru/post/1777514/


All Articles