WordPress Reindirizza tutte le richieste HTTP a HTTPS tramite .htaccess
-
-
Prova atracciareil reindirizzamento: http://redirectdetective.com/Try tracing the redirect: http://redirectdetective.com/
- 1
- 2016-08-22
- jdm2112
-
Testato (domanda aggiornata coninformazioni aggiuntive) - Hopersino disabilitato la cache di Google Chromeperevitareproblemi come questo,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
-
Haiprovatonell'altromodointorno?`RewriteCond% {SERVER_PORT}! ^ 433 $`Have you tried the other way arround? `RewriteCond %{SERVER_PORT} !^433$`
- 0
- 2016-08-22
- David
-
Con la risposta [cheti ho datonellatua domandaprecedente] (http://wordpress.stackexchange.com/q/236727/98212),questonon ha risoltotuttii tuoiproblemi HTTPS?O lo staifacendoper rafforzare HTTPS sultuo sito web?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
-
Hafattoper quella domanda sì,grazie.Voglio riordinaretuttoin modo che se qualcuno accede alla versione http del sito viene reindirizzato 301 a https.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 questo dovrebbeessere sistemato automaticamente quando hai aggiornato la homepagee l'URL del sitopertuttoiltempo che hai leimpostazionipredefinite `.htaccess` che sono stategenerate da WordPress.@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
-
È strano.Sembraeseguire automaticamenteil reindirizzamento 301 sulla homepage,manon sul resto del sito.Vedi qui,questapagina è ancora accessibile su HTTP,http://www.michaelcropper.co.uk/contact-me/- Test sul sitopersonaleprima diessere distribuito ovunque.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
-
Assicurati di usare `@ EthanJinksO'Sullivan` così ricevo unanotifica quando rispondie posso ricontattarti rapidamente.Ti do lamia risposta di seguitoBe 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 risposta
- voti
-
- 2016-08-23
Capisco,quandoinserisci un link allatuapagina diversa dallatua home,esempio:
http://www.michaelcropper.co.uk/contact-me
www.michaelcropper.co.uk/contact-me
michaelcropper.co.uk/contact-me
Se
https://
non ènelprefisso,vieneinvece caricatoil collegamento HTTP. Aggiungi quanto segue altuo.htaccess
trailtag<IfModule mod_rewrite.c>
:RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
Senon sono state apportate ulteriorimodifiche altuo
.htaccess
,dovrebbeessereil seguente:# 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
Fammi sapere come va.
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.
-
Grazie @ EthanJinksO'Sullivan questo hafunzionato.Stranamente,hotrovato un'altra configurazionein cui avevo questo lavoro cheeramolto simile alla configurazione originale che hoprovatoe che hafunzionato anche questamattina `RewriteCond% {SERVER_PORT} 80 RewriteRule ^ (. *) $ Https://www.michaelcropper.co.uk/$1 [R=301,L] `- Sullabase di ciò,dovreipresumere che qualcosa da qualcheparte sia statomemorizzatonella cache.Chi lo saper certo.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
-
Ho dovuto riscrivereil codice dopo RewriteBase \.I had to rewrite the code after the RewriteBase \.
- 1
- 2018-10-24
- Harish ST
-
Non hafunzionatoperme: le regole https sembrano dover venireprima,perpoter lavorare anche con lepagineinterne.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
-
Come hanno dettogli altri commentatori: devi **inserire le due righe subito dopo `RewriteBase/` **.Nellaposizionemostratanella risposta,funzionerà soloper laprimapagina.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
Aggiungi codice all'interno di unfile .htaccess
<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
Puoiimpostare l'intestazionein .htaccess
<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>
-
Questomi ha aiutato,mentrenessuno deiprecedenti hafunzionato.This helped me, while none of the above worked.
- 0
- 2020-01-07
- Clain Dsilva
-
+1 Questo hail vantaggio che èmenoprobabile cheprovochi conflitti con le regoleesistenti di `mod_rewrite.c`+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
prova questoneltuo
.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
Aggiungilo altuofile .htaccess
# 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
-
qualche spiegazioneper cui questo codice risolverebbe la domanda di OP è sempre carinasome explanation why this code would solve OP's question is always nice
- 0
- 2018-05-28
- cjbj
-
- 2018-07-19
Se stai usando W3 Total Cache,la risposta di @Ethan Jinks O'Sullivanfunzionerà solo seinserisciil reindirizzamentoprima dellemod W3 Total Cachein .htaccess comemostrato di seguito
#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
Prendimi 10minutiper risolvereilproblema
Aggiungi unfile di configurazioneperiltuo dominio.
Vai a centos 7 su
/etc/httpd/conf.d/
,quindi crea unfile di configurazione chiamatoanything.conf
.Inserisciil seguente codice su diesso:
<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>
Sostituisci
example.com
coniltuo dominio.
Quindi aggiungiil codice di riscrittura https su .htaccess,funzionerà.:)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
Senon desiderimodificarenulla su .htaccess,puoiprovare
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(); } }
Oppureprova questoplugin: HTTPS Redirect
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
-
In chemodo latua risposta è diversa da @ChrisSprague?How is your answer different from @ChrisSprague?
- 1
- 2019-08-13
- nmr
L'hofattomolte voltein passato,eppurenon riesco afarlo dinuovoper qualchemotivo sconosciuto.Hoprovatoinfinite soluzioni.Tutto ciò che hoprovato sitraducein un ciclo di reindirizzamentoinfinito.
Qual è l'opzionemiglioreperfarlo?
Aggiorna 1 Ecco alcune delle coseprovate;
E;
Testatoin diversibrowserperevitareproblemi dimemorizzazionenella cache.Ancoraniente,solo ottenere un ciclo di reindirizzamento continuo.