我最近一直在研究一个工具。它从网站上获取所有链接地址。
我的问题是html代码中的链接有时是不同的:
我需要让所有的链接都一样:
/index.php -> http://www.website.com/index.php
index.php -> http://www.website.com/index.php
http://www.website.com/index.php -> http://www.website.com/index.php谢谢你帮忙。
发布于 2010-01-28 07:38:55
使用preg_replace修复相对urls
需要:
$domain =主题站点域
$path =您要查找的相对链接的文档或字符串。
返回:
$url =带链接的加号或字符串,其中的链接与给定的域转换为适当的urls。
代码:
$url = preg_replace('<a\shref="([\/\?\w\.=\&]+)"([\s]rel="(\w+)")*>/', '<a href="http://{$site_domain}$1" rel="$3">' $path) 祝你好运,告诉我事情进展如何。
发布于 2010-01-28 06:55:35
欢迎来到GoogleOverflow.com。
以下是使用parsing解析HTML链接的完整教程:http://www.the-art-of-web.com/php/parse-links/
发布于 2010-01-28 06:55:42
这是一个函数,它将返回给定基(当前) URL和相对URL的绝对URL。
https://stackoverflow.com/questions/2152808
复制相似问题