Ensuring that your WordPress website uses HTTPS instead of HTTP is a crucial step for security and SEO. In this post, we'll guide you through the process of redirecting all HTTP traffic to HTTPS on your WordPress website by modifying the .htaccess file on your WordPress site. This method is both efficient and straightforward, especially when you have an SSL certificate already installed on your hosting server.
You can find the ".htaccess" file in the root directory of your WordPress installation (the same place as wp-config.php).
1. First make a backup of your .htaccess file in case something goes wrong.
2. Now Access it via an FTP client or your hosting file manager.
3. Add the following code at the top of your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
4. Save your changes and visit your website using http://. It should automatically redirect to https://. Ensure all pages load correctly.
By adding the above code to your .htaccess file, you can now rest assured that both your users' data and your site's search engine performance are protected. If you run into any issues, remember to check for SSL certificate installation or mixed content problems to fully complete your site's migration to HTTPS.