更改 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>

每個網站都有一個,其中包含正確的網域資訊。

然後我繼續處理每個 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 的資料庫值也會導致相同的問題。

相關內容