I set up a testserver for our main website www.example.com
.
I set the apache-sites-config to www2.example.com
.
I deleted the .htaccess
/ adjusted it to hold the basic wordpress-entries.
I disabled the autocompletion of the browser.
When I enter www2.example.com
I get redirected with moved permanently to www.www2.example.com
.
When I enter 192.168.0.1
I get redirected to www.www2.example.com
.
Could somebody tell where the error might be?
.htaccess
:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
sites-config for the first vHost
:
<VirtualHost *:80>
Protocols h2 http/1.1
ServerAdmin [email protected]
DocumentRoot /var/www/html/
ServerName www2.example.de
ServerAlias www2.example.de
<Directory /var/www/html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
Protocols h2 h2c http/1.1
DocumentRoot /var/www/html/
ServerName www2.example.de
ServerAlias www2.example.de
# added 01.04.2019 BEGINN
<Directory /var/www/html>
Options -Indexes +FollowSymLinks
AllowOverride all
Order allow,deny
allow from all
</Directory>
# added 01.04.2019 END
<Directory /var/www/html/>
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine off
</VirtualHost>
</IfModule>
sites-config for second vHost
<VirtualHost *:80>
Protocols h2 http/1.1
ServerAdmin [email protected]
DocumentRoot /var/www/html1/example2/
ServerName www2.example2.eu
ServerAlias www2.example2.eu
<Directory /var/www/html1/example2>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The request- and response-header for www2.example.de
Connection: Keep-Alive
Content-Length: 236
Content-Type: text/html; charset=iso-8859-1
Date: Wed, 26 May 2021 10:41:46 GMT
Expires: Wed, 26 May 2021 10:42:46 GMT
Keep-Alive: timeout=5, max=100
Location: https://www.www2.example.de/
Server: Apache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:de,en-US;q=0.7,en;q=0.3
Cache-Control: no-cache
Connection: keep-alive
DNT: 1
Host: www2.example.de
Pragma: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0
192.168.0.1
(the IP address) then the vHost you've posted wouldn't necessarily be called, unless this is the first vHost defined? Aside: You have duplicated some directives and mixing old Apache 2.2 and 2.4 authorisation directives.www.www2.example.com
resolve? You are referring towww2.example.com
in the question text, but your vHost definitions do not use this ServerName - please clarify. Check the HTTP response headers of the redirect - make sure it's not a cached redirect and check if there is a clue as to what is triggering the redirect... is it WordPress? (WP adds a header if it is.)