使用 PHP 在 html 源代码中更改 link 地址
Use PHP change link address in html source code
嘿呀谢谢你来看我
现在正在尝试学习如何在 php 中编写代码,以修复一个简单的 Url 代理,只需将 url 放在 www.Proxy.info/?u= 之后即可工作正常,除了它不会改变嵌入的文件路径
所以在我尝试代理的网站源代码中,我有一个像这样的地址 /images/image.jpg
或 https://Somesite.com/js/file.js
并导致问题,因为现在被代理的网站认为我的服务器上有文件
我需要添加到我的代理服务器地址 (www.Proxy.info/?u=),这样它将使用现在代理的站点文件并使其工作,例如 http://www.Proxy.info/?u=/images/image.jpg
或 http://www.Proxy.info/?u=https://Somesite.com/js/file.js
有一个代理this,但它使用的是nginx,我不太喜欢nginx,这是第二个例子,有点简单
我把它当作
https://www.proxy.info/lib/fonts/source-code-pro-v14-latin-regular.woff2
但我需要它作为
https://www.proxy.info/?u=https://www.Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2
或者
https://www.Proxy.info/?u=Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2
如果你能编辑我的代码来修复那将是最好的,因为我添加代码非常糟糕
如果您正在使用 html form
然后设置表单方法 GET
和输入字段 name="u"
并使用 php $_GET['u']
来捕获查询 url.这是我的评论,但现在不能评论。此外,您没有共享 php 代码,因为不完全确定必须在何处进行 add/make 更改。请更新您的 post/codes.
更新答案:
正如我所看到的,您正在使用这个 github 开源:php-ultra-small-proxy
在 index.php
中使用此完整代码:
<?php
set_time_limit(0);
include __DIR__.'/UltraSmallProxy.php';
if(isset($_GET['u']))
{
$url = $_GET['u'];
$proxy = new UltraSmallProxy();
$output = $proxy->load($url); // <-- specify start page here
echo $output;
}
?>
<form method="GET">
<input type="url" name="u" placeholder="Enter proxy visit url" required>
<input type="submit" value="go">
</form>
我用 isset() Function
来检查一个变量是否是 empty/set/declared。另一件事是 $_GET
,它是一个 php 超级全局变量,参数是 u
。添加这个超级全局变量和参数你会得到这样的 (https://www.proxy.info/?u=https://www.Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2
) get request url.
嘿呀谢谢你来看我
现在正在尝试学习如何在 php 中编写代码,以修复一个简单的 Url 代理,只需将 url 放在 www.Proxy.info/?u= 之后即可工作正常,除了它不会改变嵌入的文件路径
所以在我尝试代理的网站源代码中,我有一个像这样的地址 /images/image.jpg
或 https://Somesite.com/js/file.js
并导致问题,因为现在被代理的网站认为我的服务器上有文件
我需要添加到我的代理服务器地址 (www.Proxy.info/?u=),这样它将使用现在代理的站点文件并使其工作,例如 http://www.Proxy.info/?u=/images/image.jpg
或 http://www.Proxy.info/?u=https://Somesite.com/js/file.js
有一个代理this,但它使用的是nginx,我不太喜欢nginx,这是第二个例子,有点简单
我把它当作
https://www.proxy.info/lib/fonts/source-code-pro-v14-latin-regular.woff2
但我需要它作为
https://www.proxy.info/?u=https://www.Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2
或者
https://www.Proxy.info/?u=Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2
如果你能编辑我的代码来修复那将是最好的,因为我添加代码非常糟糕
如果您正在使用 html form
然后设置表单方法 GET
和输入字段 name="u"
并使用 php $_GET['u']
来捕获查询 url.这是我的评论,但现在不能评论。此外,您没有共享 php 代码,因为不完全确定必须在何处进行 add/make 更改。请更新您的 post/codes.
更新答案:
正如我所看到的,您正在使用这个 github 开源:php-ultra-small-proxy
在 index.php
中使用此完整代码:
<?php
set_time_limit(0);
include __DIR__.'/UltraSmallProxy.php';
if(isset($_GET['u']))
{
$url = $_GET['u'];
$proxy = new UltraSmallProxy();
$output = $proxy->load($url); // <-- specify start page here
echo $output;
}
?>
<form method="GET">
<input type="url" name="u" placeholder="Enter proxy visit url" required>
<input type="submit" value="go">
</form>
我用 isset() Function
来检查一个变量是否是 empty/set/declared。另一件事是 $_GET
,它是一个 php 超级全局变量,参数是 u
。添加这个超级全局变量和参数你会得到这样的 (https://www.proxy.info/?u=https://www.Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2
) get request url.