![](/img/trans.png)
[英]Wordpress: assigning a single DIV different IDs on single.php and index.php returns 500 error
[英]WordPress : Error 500 only with index.php
我實際上是在為一家小型公司的網站上工作。 首先,我在安裝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日志的虛擬主機...有人有想法嗎? (對不起我的英語不好。)
檢查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');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.