Wordpress站点在LAN中加载但不从WAN加载,但父方向加载两者

时间:2018-01-04 05:49:08

标签: php html wordpress .htaccess

-------------------------解决--------------------- ----

请参阅@fubar的评论部分中的解决方案。

目标:使用Web Station Suite在我的Synology上设置Wordpress网站。使用no-ip中的免费ddns使其可访问。

当前状态:可以在http://192.168.1.157:888/wordpress/的LAN中访问网站。但是http://tnz.ddns.name:888/wordpress/无法从WAN访问它。

但是,http://192.168.1.157:888/index.htmlhttp://tnz.ddns.name:888/index.html都会加载。

192.168.1.157:888是Web Station的父目录,它将加载' index.html'在下图中: Web Station Directory

192.168.1.157:888/wordpress/显然是Wordpress网站的目录,文件夹的结构如下所示: directory of the Wordpress site

下面是我能找到的唯一相关的相关设置项。 Wordpress Settings

总结,除了wordpress文件夹外,一切都会加载,我非常怀疑它是wordpress的设置问题。然而,我没有找到有类似情况的人。

.htaccess文件内容:

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

# END WordPress

wp-config.php文件内容:

<?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, and ABSPATH. You can find more information by visiting
 * {@link https://codex.wordpress.org/Editing_wp-config.php Editing wp-config.php}
 * Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME','wordpressblog');

/** MySQL database username */
define('DB_USER','wordpress');

/** MySQL database password */
define('DB_PASSWORD','');

/** 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
 */
/*keys are deleted here just to be safe on the web :P*/
define('AUTH_KEY',' '); 
define('SECURE_AUTH_KEY',' ');
define('LOGGED_IN_KEY',' ');
define('NONCE_KEY',' ');
define('AUTH_SALT',' ');
define('SECURE_AUTH_SALT',' ');
define('LOGGED_IN_SALT',' ');
define('NONCE_SALT',' ');

/**#@-*/

/**
 * 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_';

/**
 * WordPress Localized Language, defaults to English.
 *
 * Change this to localize WordPress. A corresponding MO file for the chosen
 * language must be installed to wp-content/language-selector/languages. For example, install
 * de_DE.mo to wp-content/language-selector/languages and set WPLANG to 'de_DE' to enable German
 * language support.
 */
define('WPLANG', 'en_En');
define('WP_LANG_DIR', '/volume1/web/wordpress/wp-content/plugins/language-selector/language-selector/languages');

/**
 * 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.
 */
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "888") {
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
} else {
    $pageURL .= $_SERVER["SERVER_NAME"];
}

$virtual_host_file = file_get_contents("/etc/httpd/sites-enabled-user/httpd-vhost.conf-user");
if (preg_match('/ServerName '.$_SERVER["SERVER_NAME"].'/', $virtual_host_file)) {
    define('WP_SITEURL', $pageURL);
} else {
        define('WP_SITEURL', $pageURL.'/wordpress');
}

if (!defined('SYNOWORDPRESS'))
    define('SYNOWORDPRESS', 'Synology Inc.');

/** 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');
require_once(ABSPATH . 'syno-misc.php');

1 个答案:

答案 0 :(得分:0)

我知道这已经有很长的历史了,但是只是为了在此处添加解决方案:

在wp-config.php中,注释掉:

if ($_SERVER["HOST"] != "") {
    define('WP_SITEURL', $pageURL);
} else {
    define('WP_SITEURL', $pageURL.'/wordpress');

这使得两个地址都可以在gui中进行编辑。