Problema con il reindirizzamento in htaccess wordpress

Aug 02 2019

Ho i seguenti reindirizzamenti in htaccess Wordpress è installato nella cartella home Il sito deve reindirizzare un esempio.com (senza www) e con https L'installazione di wordpress è in / home

E non so come risolverlo. Eventuali suggerimenti? Grazie !!

RewriteCond %{HTTP_HOST} ^example.com$ RewriteCond %{REQUEST_URI} !^/home/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /home/$1 RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(/)?$ home/index.php [L] # BEGIN SSL <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^example\.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>

 # END SSL```

Risposte

2 RohitKaushik Aug 02 2019 at 17:40

Non è possibile forzare il reindirizzamento di una sottocartella o sottodominio a https

per il reindirizzamento https basta usare questo

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Per sottocartella

RewriteRule ^/?(.*) https://%{SERVER_NAME}/home/$1 [R,L]

inoltre puoi usare il .htaccess predefinito per il reindirizzamento

<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>