如何使用我的特殊链接替换所有链接? [英] How do I replace all links with my special link?

查看:84
本文介绍了如何使用我的特殊链接替换所有链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用正则表达式替换所有链接甚至相对链接与https://snowycinccino.com/iframe/?url=(这里的旧URL和URL的基础,如果它包括)我需要它与href和src。



我尝试了什么:



这是我目前的代码:



<?php 
$ newurl = parse_url($ _ GET [url]);
$ base = $ newurl [scheme]。://。$ newurl [host]。/;
$ basenew = $ newurl [scheme]。://。$ newurl [host];
?>

<?php
$ input = $ page = file_get_contents($ _ GET [url]);

$ domain = $ base;
$ rep ['/ href =(?!https?:\ / \ /)(?! data :)(?!#)/'] ='href ='。$ domain;
$ rep ['/ src =(?!https?:\ / \ /)(?! data :)(?!#)/'] ='src ='。$ domain;
$ rep ['/ @ import [\ n + \ s +]\ //'] ='@ import'。$ domain;
$ rep ['/ @ import [\ n + \ s +]\。/'] ='@ import'。$ domain;
$ output = preg_replace(
array_keys($ rep),
array_values($ rep),
$ input
);

echo $ output;
?>

解决方案

newurl = parse_url(


_GET [url ]);

基=

I am trying to use regex to replace all links even relative links with https://snowycinccino.com/iframe/?url=(Old URL here and base of url if it includes) I need it to work with href and src.

What I have tried:

This is my current code:

<?php
$newurl=parse_url($_GET["url"]);
$base=$newurl["scheme"]."://".$newurl["host"]."/";
$basenew=$newurl["scheme"]."://".$newurl["host"];
?>

<?php
$input = $page = file_get_contents($_GET["url"]);

$domain = $base;
$rep['/href="(?!https?:\/\/)(?!data:)(?!#)/'] = 'href="'.$domain;
$rep['/src="(?!https?:\/\/)(?!data:)(?!#)/'] = 'src="'.$domain;
$rep['/@import[\n+\s+]"\//'] = '@import "'.$domain;
$rep['/@import[\n+\s+]"\./'] = '@import "'.$domain;
$output = preg_replace(
    array_keys($rep),
    array_values($rep),
    $input
);

echo $output;
?>

解决方案

newurl=parse_url(


_GET["url"]);


base=


这篇关于如何使用我的特殊链接替换所有链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆