国内外主机
测评及优惠码

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

织梦文章内链com/tag/712/" title="查看含有 绝对路径 标签的文章" target="_blank">绝对路径的跳过,相对路径的替换
替换之前
<p><https://www.ibytx.com/tag/213/" title="查看含有 href 标签的文章" target="_blank">href="https://www.ibytx.com/tag/829/" title="查看含有 strong 标签的文章" target="_blank">strong><a href=”/html/1.html”>HTML</a>文档是由<a href=”http://dede97.com/html/2.html”>HTML</a>元素构成的文本文件。</strong></p>
<p><strong><a href=’/html/3.html’>HTML</a>元素是通过使用<a href=”http://dede97.com/html/4.html”>HTML</a>标签进行定义的。</strong></p>
替换之后
<p><strong><a href=”http://dede97.com/html/1.html”>HTML</a>文档是由<a href=”http://wwwdede97.com/html/2.html”>HTML</a>元素构成的文本文件。</strong></p>
<p><strong><a href=’http://dede97.com/html/3.html’>HTML</a>元素是通过使用<a href=”http://dede97.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}

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《织梦模板正则批量替换文章内容内链变成绝对路径的方法》
文章链接:https://www.ibytx.com/681.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

登录

找回密码

注册