0

I have the following VirtualHosts inside /etc/httpd/sites-enabled/domain.com.conf:

<VirtualHost *:80>
        DocumentRoot /var/www/html/
        ServerName www.domain1.com
</VirtualHost>

<VirtualHost *:80>
        ServerName test.domain2.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/domain2dir
        ErrorLog /var/log/httpd/domain2.com-error.log
        CustomLog /var/log/httpd/domain2.com-access.log combined
</VirtualHost>

<VirtualHost *:80>
        ServerName something.domain1.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/somethingdir
        ErrorLog /var/log/httpd/something.domain1.com-error.log
        CustomLog /var/log/httpd/something.domain1.com-access.log combined
</VirtualHost>

When I access my server via IP, it shows me /var/www/html/; [OK]

When I access my server via something.domain1.com, it shows me/var/www/html/somethingdir; [OK]

But when I access test.domain2.com, it returns me to http://IP/ instead of taking me to /var/www/html/domain2dir.

Why is that?

PS: domain2dir is a wordpress site.

EDIT: I changed DocumentRoot /var/www/html/domain2dir to something other than domain2dir and it works. I think this means that the problem is the wordpress directory, but I'm not sure why.

Running CentOS 7 with Apache 2.4.6 and PHP 7.2.9.

4
  • Check your WordPress settings. May 15, 2019 at 3:10
  • The WordPress is not mine, it's only hosted here. I asked the guy in charge and he has no idea why this is happening, so I'm not sure what to do.
    – Asdra
    May 15, 2019 at 11:48
  • wordpress sucks at this type of thing. During installation you specify what hostname it should use and after that anything else just gives chaos.
    – wurtel
    May 15, 2019 at 12:47
  • I asked him to change inside WordPress so it would point to test.domain2.com, but when I try to access it via test.domain2.com, it redirects me to IP. And if I try with IP/domain2dir, it redirects me to test.domain2.com/domain2dir. No idea why this is happening.
    – Asdra
    May 15, 2019 at 14:19

1 Answer 1

0

For everyone with the same problem, it was inside WordPress's database. It was pointing to http://IP/domain2dir/etc.etc.etc, so every time Apache redirected to that particular directory, WordPress redirected back to http://IP/. The solution is to change your http://IP/dir/ inside a few tables to http://domain/.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .