I am running 2 websites on the same server:
www.example.com
example.com
– WordPresssub.example.com
– another site
Requesting http://sub.example.com
should of course respond with the index for that website. Instead it redirects to http://www.example.com
unless I explicitly request http://sub.example.com/index.html
, in which case I get the correct website.
I think the issue may be WordPress’s .htaccess file for permalinks (generated by 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>
Here are my VirtualHost conf files for both sites:
# sub.mysite.com
<VirtualHost *:80>
DocumentRoot /var/www/sub
ServerName sub.example.com
<Directory /var/www/sub/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</Directory>
# www.example.com example.com
<VirtualHost *:80>
DocumentRoot /var/www/wordpress
ServerName www.example.com
ServerAlias example.com
<Directory /var/www/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</Directory>
2
Answers
Turns out it was just my browser caching a permanent redirect from
sub
towww
, which was probably the result of an improper configuration that I fixed before.Try replacing your server IP after