I'd steer clear on editing the .htaccess
if you're just updating your website from HTTP to HTTPS. Try an alternative route:
First, revert your .htaccess
back to the default settings:
# 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
Next, you need to ensures that all of the URLs for your website are up-to-date, try the following steps using the Search Replace DB tool:
- Go and download Interconnect IT's Database Search & Replace Script here
- Unzip the file and drop the folder in your localhost where your WordPress is installed (the root) and rename the folder to
replace
(screenshot)
- Navigate to the new folder you created in your browser (ex:
http://web.site/replace
) and you will see the search/replace tool
- It should be pretty self-explanatory up to this point: enter your HTTPS link in the
search for…
field and the new HTTPS link in the replace with…
field
You can click the dry run button under actions to see what it will be replacing before you execute the script. Once you're done be sure to remove the /replace/
folder.
However...
If you still insist on having your HTTP redirect to HTTPS via the .htaccess
add the following in between the <IfModule mod_rewrite.c>
tag:
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
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