admin管理员组文章数量:1122832
I'm migrating a site that uses subdomains. I want to test the subdomain's work on my machine before fully migrating the site. So I've chosen a fake domain name for my site, given it a subdomain name, and set it up with an Apache server. The domains are:
main = www.mysite
subdomain = app.mysite
I have set my host configuration file on Windows to be the following:
# My DNS overrides
<my-aws-ip> www.mysite
<my-aws-ip> app.mysite
Where <my-aws-ip>
is the IP address of the EC2 instance I'm testing on. My configuration file for my Apache server is the following:
<VirtualHost *:80>
ServerName www.mysite
DocumentRoot /var/www/mysite
<Directory /var/www/mysite>
Allowoverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/mysite-error.log
CustomLog /var/log/httpd/mysite-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName app.mysite
DocumentRoot var/www/mysite_app
<Directory /var/www/mysite_app>
Allowoverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/app_mysite-error.log
CustomLog /var/log/httpd/app_mysite-access.log combined
</VirtualHost>
However, when I visit my site I get redirected to an actual site called . Why is this? Does WordPress automatically redirect, and how can I prevent this from happening?
I'm migrating a site that uses subdomains. I want to test the subdomain's work on my machine before fully migrating the site. So I've chosen a fake domain name for my site, given it a subdomain name, and set it up with an Apache server. The domains are:
main = www.mysite.com
subdomain = app.mysite.com
I have set my host configuration file on Windows to be the following:
# My DNS overrides
<my-aws-ip> www.mysite.com
<my-aws-ip> app.mysite.com
Where <my-aws-ip>
is the IP address of the EC2 instance I'm testing on. My configuration file for my Apache server is the following:
<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot /var/www/mysite
<Directory /var/www/mysite>
Allowoverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/mysite-error.log
CustomLog /var/log/httpd/mysite-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName app.mysite.com
DocumentRoot var/www/mysite_app
<Directory /var/www/mysite_app>
Allowoverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/app_mysite-error.log
CustomLog /var/log/httpd/app_mysite-access.log combined
</VirtualHost>
However, when I visit my site I get redirected to an actual site called https://www.mysite.com
. Why is this? Does WordPress automatically redirect, and how can I prevent this from happening?
1 Answer
Reset to default 1As mentioned by Pat in the comments, my home
and siteurl
config values were set to https://www.mysite.com
and https://app.mysite.com
respectively. These values are held inside your site's database. I think you can change them through the Wordpress admin page, or you can enter your database directly and find them with the following command:
SELECT * FROM wp_options WHERE option_name = 'siteurl' OR option_name = 'home';
In my case, the protocol for siteurl
and home
was https
not http
. I believe this meant Wordpress was redirecting traffic to https://www.mysite.com
, but as my virtual hosts file doesn't handle that traffic this caused a redirect to a public DNS server and gave me the incorrect site.
(Could someone with more experience please confirm if this accurate?)
To fix the issue, I altered the siteurl
and the home
options to use the http
protocol, which can be done from within your database using the following commands:
UPDATE wp_options SET option_value = 'http://www.mysite.com' WHERE option_name = 'home';
UPDATE wp_options SET option_value = 'http://www.mysite.com' WHERE option_name = 'siteurl';
I used these commands on the databases for both my sites, and it resolved the problem.
本文标签: multisiteHow do I test my Wordpress subdomains on AWS during migration
版权声明:本文标题:multisite - How do I test my Wordpress subdomains on AWS during migration? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736305924a1932765.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
home
and/orsiteurl
are set tohttps://www.mysite.com
. – Pat J Commented May 25, 2024 at 17:41