Korrkter seofreundlicher redirect bei Umstellung auf https
am 18.04.2018 - 19:13 Uhr in
Aufgrund des DSGVO Wahnsinns werden hier einige auch ihre Seite auf ssl/https umstellen. Dabei sollte das SEO-Freundlich sein.
Ich habe das erfolgreich dank "letsencrypt" durchgeführt. Allerdings gib es bei den .htaccess redirects ein Problem.
Hier der Auszug
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
#ssl an
#To force all of the web traffic (every link in your website) to use HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Set "protossl" to "s" if we were accessed via https://. This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
# Make sure Authorization HTTP header is available to PHP
# even when running as CGI or FastCGI.
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or
# Git to store control files. Files whose names begin with a period, as well
# as the control files used by CVS, are protected by the FilesMatch directive
# above.
#
# NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
# not possible to block access to entire directories from .htaccess, because
# <DirectoryMatch> is not allowed here.
#
# If you do not have mod_rewrite installed, you should remove these
# directories from your webroot or otherwise protect them from being
# downloaded.
RewriteRule "(^|/)\." - [F]
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /http://www.ADRESSE.de
301 Moved Permanently
https://www.ADRESSE.de/
200 OK
Das funktioniert so zwar, ABER! Ohne www passiert allerdings ein doppelter 301 redirect. Das will ich vermeiden. Ich will nur einen 301 redirect.
http://ADRESSE.de
301 Moved Permanently
https://ADRESSE.de/
301 Moved Permanently
https://www.ADRESSE.de/
200 OK
Hat da von euch eventuell jemand eine Idee. Ich habe übrigend absichtlich keine festen URLs eingetragen sondern will das dynamisch lösen. Danke.
- Anmelden oder Registrieren um Kommentare zu schreiben

Ich mache das im Grunde
am 19.04.2018 - 06:38 Uhr
Ich mache das im Grunde ähnlich wie Du, nur dass zuerst die Weiterleitung von ohne auf mit www passiert.
Das ist übrigens die offizielle Variante von Drupal 8:
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/foo will be redirected to http://www.example.com/foo)
# uncomment the following:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/foo will be redirected to http://example.com/foo)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Um die doppelte Weiterleitung zu vermeiden, müsste man vermutlich schreiben
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
statt
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Vielleicht macht man das nicht, damit die Seite auch noch funktioniert, wenn https mal nicht funktioniert?
Ich kann nicht sagen, wie kritisch die doppelte Weiterleitung ist.
Dass es in Drupal original so drinnen steht, ist kein Argument, weil unter D7 auch eine Anpassung der robots-DAtei nötig war, damit Google nicht jammert.
Danke.Die robots.txt? Da
am 19.04.2018 - 08:20 Uhr
Danke.
Die robots.txt? Da stehen doch nur relative urls drin. Da müsste man doch theoretisch nix anpassen.
Also es sei denn man hat da absolute adressen reingepackt.
Ich habe jetzt mal den Vorschlag getestet. Vielen Dank.
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# uncomment the following:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Result
http://URL.de
301 Moved Permanently
https://www.URL.de/
200 OK
http://www.URL.de
301 Moved Permanently
https://www.URL.de/
200 OK
https://www.URL.de
200 OK
https://URL.de
301 Moved Permanently
https://www.URL.de/
200 OK
www.url.de redirectet auch 301 auf https://www.URL.de
Alles korrekt, aber ja so funktioniert nur https, was an sich auch mein Plan war. Falls das jemand anders ließt, bitte bedenken. In einem letsencrypt CERT kann man auch ssl force aktivieren. Vermutlich macht das dasselbe bzw. lässt auch nur https zu. Danke auf jeden Fall.
Da es soweit funktioniert habe ich es auch auf die doc Seite gepackt, als das es jedem weiterhelfe: https://www.drupal.org/https-information
Es gab doch mal die
am 19.04.2018 - 08:34 Uhr
Es gab doch mal die Umstellung bei Google - 2014 ??? - dass ab da auch CSS und JS für Indexierung gecrawlt wird.
In der Default-robots von Drupal 7 waren aber die Verzeichnisse mit Scripten verboten.
Das hat bei Google zu Fehlermeldungen geführt und wurde lange nicht geändert.
Ich hatte das dann in meinen Robots angepasst.
Ah achso. Danke. Garde mal
am 19.04.2018 - 08:48 Uhr
Ah achso. Danke. Grade mal einen Blick in die robots geworfen ob der /files Ordner betroffen ist. Bei mir nicht so. Das trifft dann wohl nur sehr alte Seiten bzw. manuelle Edits.
Ja, wurde inzwischen
am 19.04.2018 - 09:39 Uhr
Ja, wurde inzwischen korrigiert.
Das betraf damals die original-Datei, ist aber eine
Das war auch nur ein Beispiel, dass man sich nicht unbedingt auf die Sinnhaftigkeit der Default-Angaben in Bezug auf SEO verlassen kann.
Aber das ist ja eigentlich eh klar. ;-)