网站程序
主页 > 技巧教程 > 网站程序 >

织梦dedecms实现正则批量替换文章内容内链变成绝对路径

2018-10-18 | 酷站 | 点击:
本篇文章给大家介绍织梦dedecms实现正则批量替换文章内容内链变成绝对路径

织梦文章内链绝对路径的跳过,相对路径的替换
 

替换之前

<p><strong><a href="/html/1.html">HTML</a>文档是由<a href="http://www.xxx.com/html/2.html">HTML</a>元素构成的文本文件。</strong></p>
<p><strong><a href='/html/3.html'>HTML</a>元素是通过使用<a href="http://xxx.com/html/4.html">HTML</a>标签进行定义的。</strong></p>

替换之后

<p><strong><a href="http://www.dede58.com/html/1.html">HTML</a>文档是由<a href="http://www.xxx.com/html/2.html">HTML</a>元素构成的文本文件。</strong></p>
<p><strong><a href='http://www.dede58.com/html/3.html'>HTML</a>元素是通过使用<a href="http://xxx.com/4.html">HTML</a>标签进行定义的。</strong></p>


内容模板文章内容标签{dede:field.body/}


改成
 

{dede:field.body runphp=yes}

$str = @me;

$content = preg_replace('/(?<=href=['"])//', 'https://www.lol9.cn/', $str);

@me = $content;

{/dede:field.body}

以上就是全部教程了,希望对大家有所帮助。

原文链接:
相关文章
最新更新