Zur Navigation

rewrite funktioniert nicht

1 ammu (Gast)

ich würde von https://ip to https://example.com nicht weiterleiten. nur http://ip zu https://example.com funktioniert. können Sie bitte helfen?

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^xx.xx.xx.xx$
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L,NE]

RewriteCond %{HTTP_HOST} ^xx.xx.xx.xx$
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L,NE]

13.07.2023 15:14

2 Jörg Kruse

Ich nehme an, dass der Browser beim Aufruf der Adresse https://xx.xx.xx.xx eine Fehlermeldung erhält, dass die Verbindung nicht sicher ist? Für eine HTTPS-Verbindung braucht es ein SSL-Zertifikat, welches in diesem Fall auf die betreffende IP-Adresse ausgestellt ist. Dieses könnte sich allerdings nur der Webhoster ausstellen lassen, der die IP-Adresse registriert hat. Für einen Webhosting-Kunden wird es wohl schwer möglich sein, von https://xx.xx.xx.xx weiterzuleiten, da der Browser ohne gültiges Zertifikat keine HTTPS-Verbindung aufbaut und somit gar nicht erst von der Weiterleitung erfährt.

13.07.2023 15:29 | geändert: 13.07.2023 15:30

3 ammu (Gast)

Thank you very much for the prompt response. yes its says its not secure. SSL certificate is issued for the domain name but not for the ip, thats the problem.

13.07.2023 15:48

4 ammu (Gast)

Danke für die antwort. Ja genau, der Browser beim Aufruf der Adresse https://xx.xx.xx.xx hat die Verbindung nicht sicher ist. Aber die domain name https://example.com hat gültig zertifikat.

13.07.2023 15:51

5 Jörg Kruse

SSL certificate is issued for the domain name but not for the ip, thats the problem.

Yes, and as an certificate typically can not be obtained for an ip address this problem unfortunately can not be solved

13.07.2023 16:21

6 ammu (Gast)

Irgendwie habe ich versucht, den htaccess wie folgt erneut zu ändern. Jetzt kann ich https://ip zu https://example.com// --> (weiß nicht double slashes am ende) umleiten, aber die Verbindung ist nicht privat und http://ip funktioniert nicht mehr.

RewriteCond %{HTTP_HOST} !^xx\.xx\.x\.xx$
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

13.07.2023 16:36

7 Jörg Kruse

RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

Dieser Regelsatz sollte http://xx.xx.xx.xx zu https://xx.xx.xx.xx weiterleiten

Jetzt kann ich https://ip zu https://example.com// --> (weiß nicht double slashes am ende) umleiten

Das wundert mich. Hast du eine Ausnahmeregelung im Browser für https://ip, dass dort keine Fehlermeldung angezeigt wird? normalerweise sollte der Browser dort hängen bleiben und nicht weitergeleitet werden. Zumindest bei Firefox und Chrome sollte das der Fall sein.

13.07.2023 16:49 | geändert: 13.07.2023 16:50

8 ammu (Gast)

I have no error message displayed except "connection not private" and there it stops.

14.07.2023 09:58

9 Jörg Kruse

Yes that is the error message I have referred to. The ssl certificate is missing or does not fit to the host (in this case to the ip address). The exact wording of the error message depends on the browser and on the language configuration of the browser. In addition Google Chrome shows an error code like for example NET::ERR_CERT_COMMON_NAME_INVALID

14.07.2023 10:39

10 ammu (Gast)

now the redirection doesnot work anymore :(

17.07.2023 09:39