首页 文章

从索引启动Wordpress站点

提问于
浏览
0

我正在尝试使用按钮从非wordpress静态主页(index.html)启动wordpress网站 .

index.html将为用户提供一个选项,可以将他们的电子邮件联系信息留给我,或者将他们重定向到我们点击“Enter”按钮时创建的wordpress网站 .

当标准wordpress index.php文件位于站点根目录时,wordpress站点工作正常 . 当我用我自己的index.html文件(使用按钮和联系人代码)替换此文件时,我无法启动wordpress index.php文件 . 我将原始wordpress index.php重命名为indexWP.php,然后使用此处的代码建议从我的新index.html文件中调用该文件:A button to start php script, how?

<form action="indexwp.php" method="get">
  <input type="submit" value="Enter">
</form>

当我使用上面的内容时,当我单击Enter时,它会给我一个404 Page Not Found错误 .

原始的Wordpress index.php看起来像这样(重命名为indexwp.php):

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');

我是一个菜鸟所以我怀疑这是我用上面的示例代码误解的东西 .

2 回答

  • 0

    您可以在.htaccess中使用以下内容(在Wordpress定义下面)

    DirectoryIndex index.html
    

    Index.html是您的页面,index.php是Wordpress的页面 .

    但是Wordpress使用没有index.php的域名作为它的主页,所以你不断被扔进你的index.html(登录页面) . 如果设置了cookie(或其他东西),则需要自动重定向到index.php .

    如果你真的想要这样的输入页面,那么更好的是在子目录中安装Wordpress . 然后你可以将/index.html重定向到/WP/index.php .

    检查this article(及其链接)以在子目录中开发Wordpress .

  • 0

    假设你使用的是apache2 web服务器,也许.htaccess可能有帮助或导致问题 .

    怎么样: DirectoryIndex index.php 规则 . 这里apache2将使用index.php作为目录列表,用户现在可以访问exapmle.com/index.html .

    更好的是为什么不创建一个home.php文件,添加index.html代码,然后引用home.php像example.com/home使用htaccess删除'.php'扩展名,如: RewriteRule ^home$ $1.php

    从来没有使用静态index.html .

    祝好运 :)

相关问题