GNU/Linux >> Linux Esercitazione >  >> Linux

Come reindirizzare da http a https usando .htaccess?

Se hai installato il certificato SSL sul tuo sito Web e desideri reindirizzare il traffico del tuo sito Web da http a https utilizzando .htaccess, devi aggiungere il codice seguente al tuo file .htaccess per il reindirizzamento.

Reindirizzamento da HTTP a HTTPS

Aggiungi la seguente riga al tuo .htaccess, se stai cercando di reindirizzare un dominio specifico da HTTP a HTTPS.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Aggiungi la seguente riga al tuo .htaccess, se stai cercando di reindirizzare una cartella specifica da HTTP a HTTPS.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]

Nota:dovrai sostituire example.com con il tuo dominio dove richiesto nel tuo codice e imposta il nome della cartella dove è richiesto.


Linux
  1. Come modificare il memory_limit nel file .htaccess

  2. Come impostare l'autenticazione di base in Apache utilizzando .htaccess

  3. Reindirizzamento a HTTPS

  4. Come posso reindirizzare il mio sito utilizzando un file htaccess (punto)?

  5. Come abilitare la registrazione error-log.txt utilizzando il file .htaccess?

Come reindirizzare da HTTP a HTTPS in Nginx

Come aprire la porta http 80 in Redhat Linux usando firewall-cmd

Come reindirizzare il tuo sito Web da HTTP a HTTPS?

Come abilitare il reindirizzamento HTTPS forzato in cPanel

Come creare un proxy HTTP utilizzando Squid su CentOS 8

Come bloccare un indirizzo IP usando .htaccess?