Permanente Umleitung in der Apache-Konfiguration des virtuellen Hosts verhält sich nicht wie erwartet

Permanente Umleitung in der Apache-Konfiguration des virtuellen Hosts verhält sich nicht wie erwartet

Ich habe mehrere Domänen, die auf dieselbe IP verweisen. RedirectPermanent funktioniert für alle Domänen einwandfrei, WENN und nur WENN die Seiten NICHT existieren und ich die 404-Standardseite meiner Website erhalte. Wenn ich im Browser eine tatsächlich existierende Seite eingebe, funktioniert die Umleitung nicht, da ich von allen Domänen, die auf diese IP verweisen, auf diese Seite zugreifen kann.

Wenn ich also die URL domaintoredirect1.com/page/not/existing eingebe, erhalte ich domainiwant.com/page/not/existing (die Weiterleitung funktioniert einwandfrei).

Wenn ich domaintoredirect1.com/page/existing eingebe, erhalte ich keine Weiterleitung und die URL bleibt domaintoredirect1.com/page/existing

Warum passiert das?

Ich würde das www auch gerne auf die Nicht-www-Version der Domäne umleiten, aber die Umleitung funktioniert in diesem Fall auch nicht: Ich bekomme beide Versionen und keine Umleitung.

Ich möchte außerdem eine andere Domänenerweiterung (.org zu .com) und das www auf die Nicht-WWW-Version der Domäne umleiten, aber die Umleitung funktioniert in diesen Fällen auch nicht: Ich erhalte www...org und nichtwww...org ohne Umleitungen auf nichtwww...com.

In diesen letzten Fällen habe ich überprüft, dass Domänen mit und ohne www beide mit einem A-Eintrag registriert sind (kann das der Grund sein?). In den anderen Fällen (Domänen wollen umleiten) ist die www-Version als CNAME registriert und ich kann nur auf die www-Version zugreifen (die Version ohne www wird auf die www-Version umgeleitet).

Dies ist dasVirtulHost-Konfigurationgefunden in sites-available

    <VirtualHost *:80>
ServerName www.domaintoredirect1.com
ServerAlias domaintoredirect1.com
Redirect permanent "/" "https://domainiwant.com/en/about-us/domaintoredirect1/"
</VirtualHost>

<VirtualHost *:80>
ServerName www.domaintoredirect2.com
ServerAlias domaintoredirect.com
Redirect permanent "/" "https://domainiwant.com/en/"
</VirtualHost>

<VirtualHost *:80>
ServerName www.domainiwant.org
ServerAlias  domainiwant.org
Redirect permanent "/" "https://domainiwant.com/"
</VirtualHost>

<VirtualHost *:80>
ServerName www.domainiwant.com
Redirect permanent "/" "https://domainiwant.com/"
</VirtualHost>

<VirtualHost *:80>
ServerName domainiwant.com
Redirect permanent "/" "https://domainiwant.com/"
</VirtualHost>

<VirtualHost *:80>
    ServerName default
    DocumentRoot /var/www/html
    <Location />
        Require all denied
    </Location>
</VirtualHost>

Ich füge hinzu:ssl_configuration-DateiAuch

 <IfModule mod_ssl.c>


<VirtualHost *:443>

ServerName   website-ws.domainIwant.com
SSLCertificateFile /etc/ssl/certs/domainIwant.com.22092020.pem
SSLCertificateKeyFile /etc/ssl/private/domainIwant-com.key
SSLCipherSuite stuff...
SSLProtocol stuff...
SSLCipherSuite stuff...


#SSLProxyEngine on

<Location />
ProxyPass  http://localhost:3000/
ProxyPassReverse  http://localhost:3000/
</Location>
</VirtualHost>


<VirtualHost *:443>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
#        AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


ServerName www.domainToRedirect1.com
ServerAlias domainToRedirect1.com
SSLCertificateFile /etc/ssl/certs/domainToRedirect1.crt
SSLCertificateKeyFile /etc/ssl/private/nginx_kmdevel.key

SSLCipherSuite stuff
SSLProtocol stuff
SSLCipherSuite stuff

</VirtualHost>



<VirtualHost *:443>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
#        AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


ServerName www.domainIwant.com
SSLCertificateFile /etc/ssl/certs/domainIwant.com.22092020.pem
SSLCertificateKeyFile /etc/ssl/private/domainIwant-com.key

SSLCipherSuite stuff
SSLProtocol stuff
SSLCipherSuite stuff

</VirtualHost>


<VirtualHost *:443>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
#        AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


ServerName domainIwant.com
SSLCertificateFile /etc/ssl/certs/domainIwant.com.22092020.pem
SSLCertificateKeyFile /etc/ssl/private/domainIwant-com.key

SSLCipherSuite EECDH+AESGCM:EDH+AESGCM
SSLProtocol -all +TLSv1.3 +TLSv1.2 +TLSv1.1
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA256 EECDH+aRSA+SHA256 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"

</VirtualHost>


<VirtualHost *:443>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
#        AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


ServerName www.domainIwant.it
ServerAlias domainIwant.it
SSLCertificateFile /etc/ssl/certs/domainIwant.it.2020.pem
SSLCertificateKeyFile /etc/ssl/private/domainIwant_2020.key

</VirtualHost>

<VirtualHost *:443>
ServerName www.domainToRedirect2.com
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias domainToRedirect2.com
SSLCertificateFile /etc/letsencrypt/live/www.domainToRedirect2.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.domainToRedirect2.com/privkey.pem
</VirtualHost>


<VirtualHost *:443>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
#        AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


ServerName rcs.domainIwant.com
SSLCertificateFile /etc/ssl/certs/domainIwant.com.22092020.pem
SSLCertificateKeyFile /etc/ssl/private/domainIwant-com.key

SSLCipherSuite stuff
SSLProtocol stuff
SSLCipherSuite stuff

</VirtualHost>

</IfModule>

Was mache ich falsch?

Ich würde auch fragen, wasServerName Standardmeine, da ich in der apache_conf-Datei keinen Verweis auf ein finde, kopiere ich dieApache-KonfigurationDatei auch

DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>
<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

verwandte Informationen