首页 > CMS > 织梦DEDE > 正文

织梦模板正则批量替换文章内容内链变成绝对路径的方法

2024-07-12 08:53:46
字体:
来源:转载
供稿:网友

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

替换之前

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

替换之后

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

内容模板文章内容标签

{dede:field.body/}

改成

{dede:field.body runphp=yes} $str = @me; $content = preg_replace('/(?<=href=['"])//', 'https://www.VeVb.com/', $str); @me = $content; {/dede:field.body}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表