WordPress新建页面跳转到指定URL网址

 时间:2026-04-26 18:19:02

在Wordpress现有的主题下,新建redirect.php文件模版,在文件中添加如下内容:

<?php/*Template Name: Redirect*/

if (have_posts()) {the_post();$pattern = ‘@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@’;preg_match($pattern, get_the_excerpt(), $matches);if ($matches[0]) header(‘Location: ‘.$matches[0]);else echo ‘Enter a URL into your page body text.’;}?>

保存文件。然后到Wordpress控制台,新建页面,在页面内容中添加你要转到的网址url,最后在编辑页面的右下角,选择页面模板为“Redirect”,保存发布页面就可以了。

  • VS如何新建ASP.NET应用程序
  • 数据报表FineReport如何设置自定义登陆界面
  • mysql设置复合主键不起作用
  • 删除/查看oracle用户和用户下的所有数据
  • TP5.0页面跳转和重定向
  • 热门搜索
    簸箕怎么读 作者简介怎么写 吃多了怎么办 我的世界怎么种蘑菇 荧光棒不亮了怎么办 方舟生存进化怎么下载 月经一直不停怎么办 干海参怎么泡发 葡萄籽油怎么吃 脾气暴躁易怒怎么办