wordpress如何做301跳转

1505
2020/12/25 9:32:59
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

wordpress如何做301跳转

Windows环境中直接修改wordpress函数就可以实现301重定向,方法如下:

1.打开根目录下的wp-blog-header.php文件。

2.在<?php后面添加以下代码:

if (strtolower($_SERVER['SERVER_NAME'])!='***.com')

{

$URIRedirect=$_SERVER['REQUEST_URI'];

if(strtolower($URIRedirect)=="/index.php")

{

$URIRedirect="/";

}

header('HTTP/1.1 301 Moved Permanently');

header('Location:https://***.com'.$URIRedirect);

exit();

}

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: 如何采用php301跳转防cc