S
S
skv0052020-05-27 02:58:46
PHP
skv005, 2020-05-27 02:58:46

How to encrypt url before go.php?

Made a go.php page to redirect external links. I would like to know how they do url encryption before go? You need to hide your domain so that the external link looks like:

<a href="/go?xxxxxxxx"> И <img src="/kartinka/vesna.png">

The redirect code is:
$links = parse_ini_file('links.ini');

if(isset($_GET['go']) && array_key_exists($_GET['go'], $links)){
  header('Location: ' . $links[$_GET['go']]);
exit;
}
else{
  header('HTTP/1.0 404 Not Found');
  echo 'Unknown link.';
}

Added to htaccess file:
RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?go=$1 [L]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2020-05-27
@skv005

base64_encode() /*_decode()

S
skv005, 2020-05-29
@skv005

Sample code can be seen in another question thread. Search in answers: Some of the old code that no longer works in php7 .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question