R
R
refsurf2018-10-29 11:32:31
PHP
refsurf, 2018-10-29 11:32:31

How to make a redirect script to links from a file in php?

I need something like this. I'm just learning and even this doesn't work for me, please fix it. That is, for any access to any page, you need to redirect to a random page from the file 1.txt
<?php
$subdomen = file('1.txt');
header('HTTP/1.1 301 Moved Permanently');
header('Location: $subdomain');
?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2018-10-29
@refsurf

$links = file('1.txt');
shuffle($links);
header('HTTP/1.1 302 Moved Temporarily');
header('Location: '.$links[0]);

https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D...

P
Pavel, 2018-10-29
@PavelMonro

<?php
$subdomen = file('1.txt');
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$subdomen);
exit();
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question