我的域名转发至 www.www.www.domain.com

我的域名转发至 www.www.www.domain.com

ubuntu server 16.04有一个 wordpress 网站并且我想将其与域名链接起来。

我设置了 DNS 记录,vutlr然后还设置了我的服务器中的虚拟主机

但是,当我输入 www.mydomain.com 时,我会转发到 www.www.www.mydomain.com

为什么会发生这种情况?

虚拟主机是:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin  [email protected]
        ServerName mydomain.com
        ServerAlias www.mydomain.com
        DocumentRoot /var/www/html/mysite

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
        CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

</VirtualHost>

我的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', 'mydbsite');

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

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

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');

/** 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',         ',<sssssssssssssssssssssssssssssssssssss');
define('SECURE_AUTH_KEY',  'sssssssssssssssssssssssssssssssssssss');
define('LOGGED_IN_KEY',    'Jssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss ');
define('NONCE_KEY',        ':sssssssssssssssssssssssssssssssssssssssssssssssssssssssss');
define('AUTH_SALT',        'sssssssssssssssssssssssssssssssssssssssssssssssssssssssss');
define('SECURE_AUTH_SALT', 'sssssssssssssssssssssssssssssssssssssssssssssssssssssssss');
define('LOGGED_IN_SALT',   'sssssssssssssssssssssssssssssssssssssssssssssssssssssssss');
define('NONCE_SALT',       'sssssssssssssssssssssssssssssssssssssssssssssssssssssssss');

/**#@-*/

/**
 * 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.



define('WP_DEBUG', false);

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

wordpess 文件夹内还有一个 htcaccess 文件

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

# END WordPress

还有来自 apache2 的错误日志

由于可能的配置错误,请求超出了 10 次内部重定向的限制。使用“LimitIn$

最后在 vultr 中的 DNS 记录中进行设置

在此处输入图片描述

答案1

我已经浪费了 3 个多小时,试图了解为什么一个简单的程序(我已经做过很多次了)不起作用......

然而,解决方案非常简单......

  1. 我在“设置 - 常规”中更改了主页和站点网址,以便获得域名。(感谢@Michael Hampton 的评论!)
  2. 然后我只需清除浏览器中的缓存,一切就都好了

...

相关内容