WordPress:只有index.php的错误500

时间:2017-02-02 12:12:31

标签: php wordpress apache .htaccess

我实际上是在一家小公司的网站上工作。起初,我正在对安装了WordPress网站的子目录(称为“站点”)进行一些测试。问题是我想最终部署我的网站而不将所有内容移动到根目录。顺便说一句,我找到了这个教程https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory并且跟着它,因为我并不完全熟悉WordPress。

到目前为止,我可以通过www.mywebsite.fr/index.php/page/访问我的所有页面。但问题是我无法访问主页面(没有“index.php / page /”甚至没有“/ page /”)。 它不断返回错误500.

.htaccess(根目录)

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>

# END WordPress

index.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( dirname( __FILE__ ) . '/site/wp-blog-header.php' );

.htaccess('/ site'目录)

RewriteEngine On
RewriteBase /site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]

index.php('/ site'目录)

<?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( dirname( __FILE__ ) . '/wp-blog-header.php' );

最重要的是,客户选择了一个没有任何php日志的虚拟主机... 有人有想法吗? (抱歉我的英文。)

1 个答案:

答案 0 :(得分:0)

检查wordpress网址是否设置为www.mydomain.com/site/ 并且站点地址设置为www.mydomain.com

它看起来像你的根.htaccess不正确,试试这个(将mydomain.com更改为你的域名)

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
    RewriteCond %{REQUEST_URI} !^/site/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /site/$1
    RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
    RewriteRule ^(/)?$ site/index.php [L] 
</IfModule>

您还可以尝试更改根index.php中的以下行:

require( dirname( __FILE__ ) . '/site/wp-blog-header.php' );

为:

require('/site/wp-blog-header.php');