For the last 3 years I've had 2 copies of my Wordpress website. One at www.domain.com and one at dev.domain.com. I'm trying to add a third today. Seems simple enough! I go through all the simple setup steps and as soon as I enable the site it's 301 directing me to the www site. I don't know how to troubleshoot what is triggering the 301. Is it somewhere in Apache or in Wordpress? All I know is that I'm copying all the configuration for the dev site and changing the subdomain and directory names wherever applicable. Seems like that should be enough. My steps:
- Open dev2.domain.com in a browser and see the default Apache2 page
- Copy source folder for /dev.domain.com -> /dev2.domain.com
- Copy /etc/apache2/sites-available/dev.domain.com.conf -> dev2.domain.com.conf
- Execute: sudo a2ensite dev2.domain.com.conf
- Execute: sudo service apache2 reload (and/or restart - I've tried both)
- Open dev2.domain.com and get 301 redirected to www.domain.com
Is there anyway to definitively figure out what's causing the 301? What's most confusing is that I'm standing up this new site on a subdomain by copying an existing site that's running on a subdomain. I just can't figure out what the difference is between the two.
Obligatory configuration info...
Identical .htaccess in root directory of all 3 sites (www, dev, and dev2):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Options +Indexes
IndexOptions -FancyIndexing
sites-available configuration for dev.domain.com...
<VirtualHost *:80>
ServerName dev.domain.com
ServerAdmin [email protected]
DocumentRoot /srv/dev.domain.com
<Directory />
Options All
AllowOverride All
Require all granted
</Directory>
ErrorLog /srv/dev.domain.com/logs/error.log
CustomLog /srv/dev.domain.com/logs/access.log combined
</VirtualHost>
sites-available configuration for dev2.domain.com...
<VirtualHost *:80>
ServerName dev2.domain.com
ServerAdmin [email protected]
DocumentRoot /srv/dev2.domain.com
<Directory />
Options All
AllowOverride All
Require all granted
</Directory>
ErrorLog /srv/dev2.domain.com/logs/error.log
CustomLog /srv/dev2.domain.com/logs/access.log combined
</VirtualHost>
DNS configuration in AWS Route53...
domain.com A 12.34.567.89
dev.domain.com A 12.34.567.89
dev2.domain.com A 12.34.567.89
www.domain.com CNAME domain.com
I guess the 2 things that I'm most stuck on:
The apache configuration between dev and dev2 seem to be identical other than changing "dev" -> "dev2" wherever applicable
When the site is disabled in apache it does not get redirected. The redirection only happens once the site is enabled. Does this mean it's Wordpress?