我在当地开发一个WordPress网站,一切进展顺利。我在VPS I控件上设置了预览站点。该帐户具有最终域,我添加了一个子域并在该子域上设置了站点。
在这一点上,大多数事情都是可行的。我可以在网站的前面导航。在后端,事情变得一团糟。管理中的几个操作强制重定向到站点的首页。例如,如果我试图用“Plain”以外的任何东西保存永久链接。无论permalinks设置如何,如果我转到外观->菜单并尝试保存,它会重定向到主页。如果我尝试使用漂亮的更新(通过ajax)更新插件,它会说它出错了,生成的输出是首页的标记。
这在本地副本上不是(现在仍然不是)问题。我已经禁用了所有插件,并将主题切换到2017年。没有骰子。WP-CLI在数据库上查找/替换,一切正常。最后要注意的是,我将核心文件保存在一个子目录中(wp
), 这意味着index.php
在“我的网站”中,root执行以下操作:
require( dirname( __FILE__ ) . \'/wp/wp-blog-header.php\' );
并且在
wp-config.php
我必须明确定义:
define(\'WP_CONTENT_DIR\', dirname(__FILE__).\'/wp-content\');
define(\'WP_CONTENT_URL\', \'http://preview.mysite.com\'.\'/wp-content\');
这可以防止它寻找
wp-content
与核心文件位于同一目录中。我已经多次使用此设置,没有任何问题。我在这个VPS上还有一个WordPress站点,使用相同的设置,但没有子域,运行良好。我把整件事都扔掉了,一开始就没用了。
有人见过这样的东西吗?
wp-config.php:
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don\'t have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://codex.wordpress.org/Editing_wp-config.php
*
* @package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define(\'DB_NAME\', \'databasehere\');
/** MySQL database username */
define(\'DB_USER\', \'userhere\');
/** MySQL database password */
define(\'DB_PASSWORD\', \'passwordhere\');
/** MySQL hostname */
define(\'DB_HOST\', \'localhost\');
/** Database Charset to use in creating database tables. */
define(\'DB_CHARSET\', \'utf8\');
/** The Database Collate type. Don\'t change this if in doubt. */
define(\'DB_COLLATE\', \'\');
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
// salts defined properly here
/**#@-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = \'wp_\';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define(\'WP_DEBUG\', false);
define(\'WP_CONTENT_DIR\', dirname(__FILE__).\'/wp-content\');
define(\'WP_CONTENT_URL\', \'http://preview.url.com\'.\'/wp-content\');
define( \'WP_HOME\', \'http://\' . $_SERVER[\'SERVER_NAME\'] );
define( \'WP_SITEURL\', WP_HOME . \'/wp\' );
/* That\'s all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined(\'ABSPATH\') )
define(\'ABSPATH\', dirname(__FILE__) . \'/\');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . \'wp-settings.php\');
以及目录结构:
- preview
- .git
- .gitignore
- .htaccess
- composer.json
- composer.lock
- index.php
- readme.md
- vendor/
- wp/
- license.txt
- readme.html
- wp-activate.php
- wp-admin
- wp-includes
- and all the other usual root files
- wp-config.php
- wp-content/ <-- has what you would expect: plugins, themes, uploads...