Ho il seguente codice in htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /films/
RewriteCond %{REQUEST_METHOD} =POST
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/films/$1 [R=301,L]
Voglio che reindirizzi automaticamente l'URL su HTTPS Ma non sta reindirizzando. Ho provato a cambiare
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/films/$1 [R=301,L]
a
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/films/$1 [R=301,L]
risposte:
2 per risposta № 1Per reindirizzare a https, è possibile utilizzare il seguente reindirizzamento in /films/.htaccess
:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /films/
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^(.*)$ https://www.example.com/films/$1 [R=301,L,NE]
Svuota la cache del browser prima di provare questo reindirizzamento.
3 per risposta № 2
Forzare HTTPs
Puoi usare:
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Quindi lasciandoti con https://
su tutto. Compreso {REQUEST_URI}
è meglio che specificare la directory. Come funzionerà quindi anche per tutte le directory.
Come ho imparato di recente, è meglio combinare i tuoi forzati www
e https
, prova a usare questo:
RewriteCond %{HTTP_HOST} !^www. [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L,NE]