Use .htaccess to redirect HTTP to HTTPs Use .htaccess to redirect HTTP to HTTPs wordpress wordpress

Use .htaccess to redirect HTTP to HTTPs


On Dreamhost, this worked:

<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{HTTPS} !=onRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]# BEGIN WordPressRewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>


Problem solved!

Final .htaccess:

<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteCond %{ENV:HTTPS} !=onRewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]# BEGIN WordPressRewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>


It works for me:

# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteCond %{HTTPS} !on           RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]RewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule># END WordPress