问题描述:wordpress首页想做一个其它的index.html页面,但是又不能影响其它的页面(都是伪静态页面,index.php删除了,其他页面都无法访问),所以只能在index.php页面进行一次判断!
具体实现代码如下:
<?php // 获取当前页面的完整 URL $currentUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; // 判断当前页面是否为 https://123.com if ($currentUrl === 'https://123.com') { include( dirname( __FILE__ ) . '/index.html' ); } else { define( 'WP_USE_THEMES', true ); // 加载 WordPress 环境 require __DIR__ . '/blog-header.php'; } ?>