Wordpress サイトの URL と VirtualHost を変更する

Wordpress サイトの URL と VirtualHost を変更する

私の状況を説明してみます。私には 2 つのドメインがあります:

www.impiantisaettasnc.it
www.oasisgaming.it

そして、アドレスの VPS でホストされている 2 つの異なるサイトを指すようにしたいと考えていますx.x.x.x

そこで、ドメインのコントロール パネルにアクセスし、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>

各サイトごとに 1 つずつ、正しいドメイン情報が含まれます。

次に、各 wp-config ファイルにアクセスし、最後に次の 2 行を追加します。

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を使用することができますDB移行プラグインローカル作業で DB をインポートします。

場合によっては、URL のデータベース値でも同じ問題が発生することがあります。

関連情報