Diese kurze Anleitung zeigt, wie man seine Seite auf https:// weiterleitet. Wenn man www. auch noch dazu braucht, dann einfach den 2. Codeschnipsel benutzen!
https:// Redirect ohne www.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
https:// Redirct mit www.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
https:// Redirect und www. entfernen
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Update 1: Mit TYPO3 GET Parameter behalten und auf https://www. weiterleiten
Für den Spezialfall TYPO3 muss man in der .htaccess unter „IfModule mod_rewrite.c“ zwischen folg. Zeilen seinen Redirect Code einfügen, damit die GET Parameter behalten bleiben:
....
# Stop rewrite processing, if we are in the typo3/ directory or any other known directory
# NOTE: Add your additional local storages here
RewriteRule ^(?:typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/) - [L]
#HIER EINFÜGEN:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# If the file/symlink/directory does not exist => Redirect to index.php.
# For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
RewriteCond %{REQUEST_FILENAME} !-f
....
Wenn Ihr auch noch Redirect Tricks via .htaccess kennt, immer her damit! Gerne in die Kommentare, dann nehme ich die in diesen Beitrag mit auf.