更改 Wordpress 网站的 URL 和 VirtualHost

更改 Wordpress 网站的 URL 和 VirtualHost

我会尝试解释我的情况。我有 2 个域:

www.impiantisaettasnc.it
www.oasisgaming.it

我希望它们指向我 VPSx.x.x.x地址上托管的 2 个不同站点。

因此我进入我的域控制面板,并为我的 VPS 的 IP 输入了 DNS A 记录x.x.x.x

接下来我进入我的服务器,并创建了 2 个单独的虚拟主机,如下所示:

 <VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName impiantisaettasnc.it
    ServerAlias www.impiantisaettasnc.it
    DocumentRoot /var/www/html/impiantisaetta

# BEGIN WordPress
        <IfModule mod_rewrite.c>
                RewriteEngine On
                RewriteRule ^index\.php$ - [L]
                RewriteCond $1 ^(index\.php)?$ [OR]
                RewriteCond $1 \.(gif|jpg|png|ico|css|js)$ [NC,OR]
                RewriteCond %{REQUEST_FILENAME} -f [OR]
                RewriteCond %{REQUEST_FILENAME} -d
                RewriteRule ^(.*)$ - [S=1]
                RewriteRule . /index.php [L]
        </IfModule>
    # 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 /var/www/html/impiantisaetta/vhost-error.log
    CustomLog /var/www/html/impiantisaetta/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 文件并在末尾附加以下两行:

define( 'WP_HOME', 'http://www.site1.it' );
define( 'WP_SITEURL', 'http://www.site1.it' );

就像我读到的官方指南。目前,域名没有显示正确的站点,我无法以任何方式访问我的控制面板,无论是使用我的 IP 还是域名作为 URL。

还有我的# apachectl -S命令输出

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server impiantisaettasnc.it (/etc/httpd/conf.d/impiantisaettasnc.it.conf:1)
         port 80 namevhost impiantisaettasnc.it (/etc/httpd/conf.d/impiantisaettasnc.it.conf:1)
                 alias www.impiantisaettasnc.it
         port 80 namevhost oasisgaming.it (/etc/httpd/conf.d/oasisgaming.it.conf:1)
                 alias www.oasisgaming.it
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html/main"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex default: dir="/run/httpd/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: _RH_HAS_HTTPPROTOCOLOPTIONS
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48

答案1

您还需要通过手动更新 phpmyadmin 来更改数据库值。

其他情况下,您可以使用 WP迁移数据库插件在本地工作上,然后导入数据库。

有时 URL 的数据库值也会导致同样的问题。

相关内容