简体   繁体   中英

WordPress : Error 500 only with index.php

I'm actually working on a website for a small company. At first, I was doing some test on a sub directory (called "site") where my WordPress website was installed. The thing is that I wanted to finally deploy my website without moving the all content to the root directory. By the way, I found this tutorial https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory and followed it as I ain't completely familiar with WordPress.

By now I can access all my pages doing www.mywebsite.fr/index.php/page/ for example. But the problem is that I can't access the main page (without "index.php/page/" or even without "/page/"). It keeps returning error 500.

.htaccess (root directory)

# 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 (root directory)

<?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' directory)

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

index.php ( '/site' directory)

<?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' );

And the best of all, the client chose a web hosting without any php log... Someone have an idea? (Sorry for my English.)

Check that the wordpress url is set to www.mydomain.com/site/ and the site address is set to www.mydomain.com

It also looks like your root .htaccess is incorrect, try this (change mydomain.com to your domain)

<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>

You can also try changing the following line in the root index.php:

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

to:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM