Wordpress上的静态主页

时间:2017-09-23 22:24:39

标签: php wordpress .htaccess

我在域http://www.example.com上有一个静态html页面,然后我在其上添加子域并安装wordpress。所以对于wordpress域http://wpdomain.example.com来说它应该是这样的。

但我想要的是http://www.example.com作为主页,其中包含我在完整之前创建的所有静态html页面,而wordpress用作博客。

我在wordpress创建的帖子会像http://www.example.com/category/post-title这样的永久链接,只有具有网址的博客页面:http://wpdomain.example.com

我怎样才能实现这一目标?因为当我尝试将主页网址的常规设置更改为http://www.example.com时,现在我无法在所有错误500处访问我的wp-admin页面,但我现在仍然可以打开博客页面{ {1}}但是当我使用网址http://www.example.com/wpdomain时,它会将我重定向回http://wpdomain.example.com

1 个答案:

答案 0 :(得分:1)

您可以使用服务器上的.htaccess文件在用户尝试访问不存在的页面时重定向

errordocument 404 /404.php

这是404.php文件:

<?php 

// get the url of the page who give an 404 error 'page doesn't exist'
$url = $_SERVER['REQUEST_URI'];

$url=substr($url,1,strlen($url));   

$path = '/wpdomain/'.$url;

$content = file_get_contents($path)

echo $content;

?>

当用户尝试访问example.com/category/post-title

他将重定向到404.php页面。

404.php会保留用户请求的网址,并会显示

的内容

example.com/wpdomain/category/post-title

相关问题