WordPress Redirect Alle HTTP-Anfragen an HTTPS über .htaccess
-
-
Versuchen Sie,die Weiterleitung zu verfolgen: http://redirectdetective.com/Try tracing the redirect: http://redirectdetective.com/
- 1
- 2016-08-22
- jdm2112
-
Getestet (aktualisierte Fragemit zusätzlichen Informationen) - Ich habe sogar den Google Chrome-Cache deaktiviert,um Probleme wie dieses zu vermeiden: http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-developmentTested that (updated question with additional info) - I've even disabled Google Chrome cache to avoid issues like this, http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development
- 0
- 2016-08-22
- Michael Cropper
-
Haben Siees anders herum versucht?`RewriteCond% {SERVER_PORT}! ^ 433 $`Have you tried the other way arround? `RewriteCond %{SERVER_PORT} !^433$`
- 0
- 2016-08-22
- David
-
Hat dasmit der Antwort [dieich Ihnenin Ihrer vorherigen Fragegegeben habe] (http://wordpress.stackexchange.com/q/236727/98212)nicht alle Ihre HTTPS-Problemebehoben?Odertun Sie dies,um HTTPS auf Ihrer Website zu verstärken?With the answer [I gave you in your previous question](http://wordpress.stackexchange.com/q/236727/98212), did that not fix all of your HTTPS issues? Or are you doing to this to reinforce HTTPS across your website?
- 0
- 2016-08-22
- Ethan O'Sullivan
-
Es hatfür diese Frageja dankegetan.Ichmöchte alles aufräumen,damitjeder,der auf die http-Version der Site zugreift,auf https umgeleitet wird.It did for that question yes thanks. I'm wanting to tidy everything up so that if anyone accesses the http version of the site they are 301 redirected to https.
- 0
- 2016-08-23
- Michael Cropper
-
@MichaelCropper Dies sollte automatischerledigt werden,wenn Sie die Home- und Site-URL aktualisiert haben,solange Sie die Standardeinstellungen ".htaccess" haben,die von WordPressgeneriert wurden.@MichaelCropper this should be automatically taken care of when you updated the home and site URL so long you have the default `.htaccess` settings that were generated by WordPress.
- 0
- 2016-08-23
- Ethan O'Sullivan
-
Esist seltsam.Scheint automatisch auf die Homepage umzuleiten,abernicht auf den Rest der Site.Siehe hier,diese Seiteist weiterhin über HTTP zugänglich,http://www.michaelcropper.co.uk/contact-me/- Testen aufpersönlicher Website,bevor sie überalleingeführt wird.It's odd. Seems to automatically 301 redirect on the homepage, but not on the rest of the site. See here, this page is still accessible on HTTP, http://www.michaelcropper.co.uk/contact-me/ - Testing on personal site before rolling out everywhere.
- 0
- 2016-08-23
- Michael Cropper
-
Verwenden Sie unbedingt "@ EthanJinksO'Sullivan",damitichbenachrichtigt werde,wenn Sie antworten,undmich schnellbei Ihnenmelden kann.Ich werde Ihnenmeine Antwort untengebenBe sure to use `@EthanJinksO'Sullivan` so I get notified when you response and I can get back to you quickly. I'll give you my answer below
- 0
- 2016-08-23
- Ethan O'Sullivan
-
9 Antworten
- Stimmen
-
- 2016-08-23
Ich sehe,wenn Sieeinen Link zu Ihrer anderen Seite als Ihrem Zuhauseeingeben,Beispiel:
http://www.michaelcropper.co.uk/contact-me
www.michaelcropper.co.uk/contact-me
-
michaelcropper.co.uk/contact-me
Wenn
https://
nichtim Präfixenthaltenist,wird stattdessen der HTTP-Linkgeladen. Fügen Sie Folgendesin Ihr.htaccess
zwischen dem<IfModule mod_rewrite.c>
-Tagein:RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
Wenn an Ihrem
.htaccess
keine zusätzlichen Änderungen vorgenommen wurden,sollte dies wiefolgt aussehen:# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # Rewrite HTTP to HTTPS RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> # END WordPress
Lassen Siemich wissen,wieesgeht.
I see, when you enter a link to your page other than your home, example:
http://www.michaelcropper.co.uk/contact-me
www.michaelcropper.co.uk/contact-me
michaelcropper.co.uk/contact-me
If
https://
is not in the prefix, the HTTP link loads instead. Add the following into your.htaccess
in between the<IfModule mod_rewrite.c>
tag:RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
If there were no additional modifications done to your
.htaccess
, it should look like the following:# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # Rewrite HTTP to HTTPS RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> # END WordPress
Let me know how it goes.
-
Danke @ EthanJinksO'Sullivan das hatfunktioniert.Seltsamerweise habeich auchein anderes Setupgefunden,bei dem diesesfunktioniert hat,das dem ursprünglichen Setup,dasichgetestet habe,sehr ähnlich war und das auch heute Morgenfunktioniert hat: `RewriteCond% {SERVER_PORT} 80 RewriteRule ^ (. *) $ Https://www.michaelcropper.co.uk/$1 [R=301,L] `- Aufgrund dessenmüssteich davon ausgehen,dassirgendwoetwas zwischengespeichert wird.Wer weiß das schon.Thanks @EthanJinksO'Sullivan this worked. Strangely too, I found another setup where I had this working which was very similar to the original setup I tested which also worked this morning `RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.michaelcropper.co.uk/$1 [R=301,L]` - Based on this I'd have to assume that something somewhere was being cached. Who knows for sure.
- 0
- 2016-08-24
- Michael Cropper
-
Ichmusste den Codenach der RewriteBase \neu schreiben.I had to rewrite the code after the RewriteBase \.
- 1
- 2018-10-24
- Harish ST
-
Hatbei mirnichtfunktioniert - https-Regelnmüssen anscheinend vorher kommen,um auchmit inneren Seiten zu arbeiten.Did not work for me - https rules seems to need to come before, in order to work with inner pages too.
- 0
- 2018-11-20
- tishma
-
Wie die anderen Kommentatoren sagten: Siemüssen ** diebeiden Zeilen direktnach `RewriteBase/` **einfügen.In derin der Antwort angegebenen Positionfunktioniert diesnurfür die Startseite.As the other commenters said: You have to **insert the two lines right after `RewriteBase /`**. In the position shown in the answer, it will only work for the frontpage.
- 3
- 2019-09-24
- tanius
-
- 2019-02-17
Codein eine .htaccess-Dateieinfügen
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # BEGIN WordPress RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
Add code within a .htaccess file
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # BEGIN WordPress RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
-
- 2018-09-11
Sie können den Headerin .htaccess
festlegen<IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS </IfModule>
You can set header in .htaccess
<IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS </IfModule>
-
Dies hatmirgeholfen,während keines der obengenanntenfunktioniert hat.This helped me, while none of the above worked.
- 0
- 2020-01-07
- Clain Dsilva
-
+1 Dies hat den Vorteil,dasses weniger wahrscheinlichist,dass Konfliktemit vorhandenenmod_rewrite.c-Regeln auftreten+1 This has the benefit that it's less likely to cause conflict with existing `mod_rewrite.c` rules
- 0
- 2020-04-27
- Dave A-W
-
- 2018-09-19
Versuchen Sie diesin Ihrem
.htaccess
:RewriteCond %{HTTP:X-Forwarded-Proto} !=https RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] </IfModule> # END WordPress
try this in your
.htaccess
:RewriteCond %{HTTP:X-Forwarded-Proto} !=https RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] </IfModule> # END WordPress
-
- 2018-05-28
Fügen Sie dieseinfachin Ihre .htaccess-Dateiein
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
Just Add this in your .htaccess file
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
-
Eine Erklärung,warum dieser Code die Frage von OP lösen würde,istimmernettsome explanation why this code would solve OP's question is always nice
- 0
- 2018-05-28
- cjbj
-
- 2018-07-19
Wenn Sie W3 Total Cache verwenden,funktioniert die Antwort von @Ethan Jinks O'Sullivannur,wenn Sie die Umleitung vor den W3 Total Cache-Modsin .htaccessplatzieren,wie untengezeigt
#BEGIN Rewrite HTTP to HTTPS <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> #END Rewrite HTTP to HTTPS # BEGIN GZIP COMPRESSION ... # END GZIP COMPRESSION # BEGIN DEFLATE COMPRESSION ... # END DEFLATE COMPRESSION # BEGIN W3TC Browser Cache ... # END W3TC Browser Cache # BEGIN W3TC Page Cache core ... # END W3TC Page Cache core # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
If you are using W3 Total Cache the answer from @Ethan Jinks O'Sullivan will only work if you place the redirect before the W3 Total Cache mods in .htaccess as shown below
#BEGIN Rewrite HTTP to HTTPS <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> #END Rewrite HTTP to HTTPS # BEGIN GZIP COMPRESSION ... # END GZIP COMPRESSION # BEGIN DEFLATE COMPRESSION ... # END DEFLATE COMPRESSION # BEGIN W3TC Browser Cache ... # END W3TC Browser Cache # BEGIN W3TC Page Cache core ... # END W3TC Page Cache core # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
-
- 2019-06-29
Ich habe 10 Minutengebraucht,um das Problem zubeheben.
Fügen Sieeine Conf-Dateifür Ihre Domain hinzu.
Gehen Sie zu Centos 7 unter
/etc/httpd/conf.d/
understellen Sieeine conf-Dateimit dem Namenanything.conf
.Geben Sie denfolgenden Codeein:
<VirtualHost *:80> ServerName domain.com ServerAlias www.domain.com ServerAdmin [email protected] DocumentRoot /var/www/html <Directory /var/www/html> Options -Indexes +FollowSymLinks AllowOverride All </Directory> ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/example.com-access.log combined </VirtualHost>
Ersetzen Sie
example.com
durch Ihre Domain.
Fügen Sie dann den https-Umschreibcode auf .htaccess hinzu,damiterfunktioniert.:)Toke me 10 minutes to fix the issue
Add a conf file for your domain.
Go to centos 7 at
/etc/httpd/conf.d/
, then create a conf file calledanything.conf
.Put the following code on it:
<VirtualHost *:80> ServerName domain.com ServerAlias www.domain.com ServerAdmin [email protected] DocumentRoot /var/www/html <Directory /var/www/html> Options -Indexes +FollowSymLinks AllowOverride All </Directory> ErrorLog /var/log/httpd/example.com-error.log CustomLog /var/log/httpd/example.com-access.log combined </VirtualHost>
Replace
example.com
with your domain.
Then add the https rewrite code on .htaccess its will work. :) -
- 2019-11-06
Wenn Sie an .htaccessnichts ändernmöchten,können Sie dies ausprobieren
add_action('template_redirect', 'redirect_core', 50); add_action('init', 'redirect_core', 50); add_action('wp_loaded', 'redirect_core', 50); function redirect_core(){ if (!is_ssl()) { wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301); exit(); } }
Oderprobieren Sie dieses Plugin aus: HTTPS-Weiterleitung
If you don't want to change anything on .htaccess you may try this out
add_action('template_redirect', 'redirect_core', 50); add_action('init', 'redirect_core', 50); add_action('wp_loaded', 'redirect_core', 50); function redirect_core(){ if (!is_ssl()) { wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301); exit(); } }
Or try this plugin: HTTPS Redirect
-
- 2019-08-13
#BEGIN Rewrite HTTP to HTTPS <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> #END Rewrite HTTP to HTTPS # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
#BEGIN Rewrite HTTP to HTTPS <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] </IfModule> #END Rewrite HTTP to HTTPS # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
-
Wie unterscheidet sich Ihre Antwort von @ChrisSprague?How is your answer different from @ChrisSprague?
- 1
- 2019-08-13
- nmr
Ich habe das schon oftgemacht,und dennoch schaffeiches auseinem unbekannten Grundnicht,diesnocheinmal zutun.Versuchteendlose Lösungen.Alles,wasich versucht habe,führt zueinerendlosen Umleitungsschleife.
Wasist diebeste Option dafür?
Update 1 Hier sindeinige der Dinge,die versucht wurden:
Und;
In verschiedenen Browserngetestet,um Caching-Probleme zu vermeiden.Immernochnichts,nureine kontinuierliche Umleitungsschleife.