2

I am trying to add custom html to a 404 page in wordpress.

<?php           
$filename = "/find";
if (!file_exists($filename))
echo $filename, " display html2 ";
elseif (!is_dir($filename))
echo $filename, " display html1 ";
?>

If someone visits http://www.demosite.com/about/whatever = Display HTML 1

If someone visits http://www.demosite.com/find/whatever = Display HTML 2

Is this even possible with PHP and HTML?

4

1 回答 1

0
<?php           
$filename = "/find";
if (is_dir($filename)){
echo $filename, " display html1 ";
include('html1.html');
}
else{
echo $filename, " display html2 ";
include('html1.html');
}
?>

此代码检查文件夹“find”是否存在,如果存在则显示 html1,否则显示 html2。

我想对你来说更好的选择是:

browse http://yourdomain/about/whatever当用户显示内容时使用 htaccesshttp://yourdomain/page.php?p=about&var=whatever

并使用 获取页面中 p 的值$_GET['p'],并相应地显示 html

if($_GET['p'] == "find"){
   include('html1.html');
}else{
   include('html2.html');
}
于 2013-02-14T04:30:17.980 回答