Replacing code in regular expressions

The problem is that links on the site are shortened, like index.php. That’s why the links don’t work on my site. How can I replace href=”ssilka.php” with href=””. Well, or somehow create a ssilka.php page on my site that would redirect to that site and save the _GET method in the link.

Answer 1, authority 100%

How can I replace href=”ssilka.php”
on the

you can replace it like this:

$pref = "";
$page = '...    href="ssilka.php"  href="ssilka2.php".';
$page = preg_replace('#href="([a-zA-Z0-9.]+)"#i', 'href="'.$pref.'$1"', $page);
echo $page;

Will output: … How can I replace href=”” with href=”http://“.

Answer 2, authority 100%

If I understand correctly, then something like this

$pattern = '/href="([^"]*)"/i';
$replacement = '/href="URL/${1}"';
preg_replace($pattern, $replacement, $YOUR_STRING);

Replaces all links in the text.