Wordpress 站点在 LAN 中加载,但不是从 WAN 加载,但父方向同时加载
Posted
技术标签:
【中文标题】Wordpress 站点在 LAN 中加载,但不是从 WAN 加载,但父方向同时加载【英文标题】:Wordpress site loads in LAN but not from WAN, yet parent direction loads with both 【发布时间】:2018-06-13 20:05:53 【问题描述】:--------------已解决---------- ----
请参阅@fubar 在 cmets 部分中的解决方案。
目标: 使用 Web Station Suite 在我的 Synology 上设置 Wordpress 网站。使用来自 no-ip 的免费 ddns 使其可访问。
当前状态: 可通过 LAN 访问站点,地址为 http://192.168.1.157:888/wordpress/。但无法通过http://tnz.ddns.name:888/wordpress/ 的 WAN 访问它。
但是,http://192.168.1.157:888/index.html 和 http://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');
【问题讨论】:
我已经很多年没有使用 WordPress,但您是否尝试过将两个 WordPress URL 设置更改为相同?我会尝试同时制作它们:tnz.ddns.name:888/index.html @fubar 感谢您的快速回复!如图所示,“WordPress 地址 URL”显示为灰色且不可写。我会搜索一下,看看有什么办法可以改变它:D 干杯 啊,好吧。这可能是 WordPress 的一个新变化。正如我所说,我有点脱节。但几乎我设置的每个实例,两个 URL 都是相同的。 @fubar 显然,造成这种情况的原因可能是 wp-config.php 或主题覆盖了这些值,因此使它们不可编辑。但是,检查后,我的 wp-config.php 没有定义这些值,我的主题也没有。我也尝试过使用不同的主题,但没有运气。然后我尝试在 phpMyAdmin 中更改该值,但 WordPress 设置中没有更新。 我重新定义了 wp-config.php 中的 URL 并强制它们相同。然而仍然没有运气。不过,感谢您的时间和帮助!!!热爱这个社区。span> 【参考方案1】:我知道这已经很久了,但只是在这里添加问题的解决方案:
在 wp-config.php 中,注释掉:
if ($_SERVER["HOST"] != "")
define('WP_SITEURL', $pageURL);
else
define('WP_SITEURL', $pageURL.'/wordpress');
这使得两个地址都可以在 gui 中进行编辑。
【讨论】:
以上是关于Wordpress 站点在 LAN 中加载,但不是从 WAN 加载,但父方向同时加载的主要内容,如果未能解决你的问题,请参考以下文章