【发布时间】:2023-04-08 11:49:01
【问题描述】:
问题总结:我有一个新的 wordpress 多站点设置为子目录(与语言子目录相同的基本 URL,例如 domain.com/en-gb/),它在除了这个非常烦人的问题之外: 每次我尝试访问主域的子页面(例如 domain.com/page/ 或 domain.com/wp-config)时,它都会重定向到该域的主页(domain.com)。
观察 1: 这种奇怪的情况只会在您第一次尝试在选项卡上加载主域的子页面时发生。例如,您在 facebook 上,看到广告,单击链接 domain.com/subpage,或者说您打开一个空白选项卡并键入 domain.com/wp-admin,您将被重定向到 domain.com。但是,如果现在从这个选项卡尝试转到子页面(任何子页面),它工作正常。这只发生在您第一次在页面上加载域时。
观察 2: 我认为问题开始于我使用插件真正简单的 SSL 启用 SSL(我不知道它可能不能很好地支持多站点)。我尝试删除它的 .htaccess 文件的一部分,但这并没有解决任何问题。在启用真正简单的 SSL 之前,我不能 100% 确定它是否有效,但我感觉它以某种方式参与其中。我不知道它是否添加了除了 .htaccess 中的行之外的任何其他内容(可能是数据库中的一些重定向?)。
观察 3: 这个问题似乎不会影响子目录。例如,如果我访问 domain.com/en-gb/page,即使在新的空白选项卡上,它也能正常工作。好像只关注主域。
永久链接设置为自定义:/%postname%/
服务器信息:Apache 主办公司:OVH PHP版本:7.3.6 MySQL 版本:5.6.43
这里是 .htaccess(已经删除了真正简单的 SSH 部分):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
# BEGIN ShortPixelWebp
# END ShortPixelWebp
仅供参考,这是 Really Simple SSH 在 .htaccess 开头添加的(我已删除):
# BEGIN rlrssslReallySimpleSSL rsssl_version[3.2.2]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
这是 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', 'XXXXXXXXXXXX');
/** MySQL database username */
define('DB_USER', 'XXXXXXXXXXXX');
/** MySQL database password */
define('DB_PASSWORD', 'XXXXXXXXXXXX');
/** MySQL hostname */
define('DB_HOST', 'XXXXXXXXXXXX');
/** 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
*/
define('AUTH_KEY', 'XXXXXXXXXXXX');
define('SECURE_AUTH_KEY', 'XXXXXXXXXXXX');
define('LOGGED_IN_KEY', 'XXXXXXXXXXXX');
define('NONCE_KEY', 'XXXXXXXXXXXX');
define('AUTH_SALT', 'XXXXXXXXXXXX');
define('SECURE_AUTH_SALT', 'XXXXXXXXXXXX');
define('LOGGED_IN_SALT', 'XXXXXXXXXXXX');
define('NONCE_SALT', 'XXXXXXXXXXXX');
/**#@-*/
/**
* 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 = 'mod155_';
/**
* 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);
/* Multisite */
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.XXXXXXXXXXXX.co');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('NOBLOGREDIRECT', 'https://www.XXXXXXXXXXXX.co' );
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/* Fixes "Add media button not working", see http://www.carnfieldwebdesign.co.uk/blog/wordpress-fix-add-media-button-not-working/ */
define('CONCATENATE_SCRIPTS', false );
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
这真的很烦人,明显降低了主网站的转化率(因为无论如何,所有的流量都被重定向到首页)
你能帮我解决这个问题吗?我拥有整个网站/数据库的所有访问权限,所以我可以尝试任何事情。
提前致谢, 马克西姆
【问题讨论】:
标签: wordpress .htaccess redirect