DEV Community

Cover image for How to Redirect www and https in WordPress?
seçil
seçil

Posted on • Updated on

How to Redirect www and https in WordPress?

First of all, let's explain what an SSL certificate is and why I should install this certificate on our sites. SSL certificate is a factor that establishes an encrypted connection between your visitors and your site. SSL certificate is a structure that must be established not only on e-commerce systems, but also in all systems. After purchasing your service from the company that provides SSL certificate service, guidance must be made on your system. So, we must first learn how this SSL redirection is done. After redirecting https:// and www from the WordPress Address (URL) section and Site Address section under the settings tab on our WordPress system, we need to add the following code in the httaccess field in the public directory. The area that needs to be edited within the Wp site

Code blog that needs to be written in Httacces

#BEGIN WordPress

RewriteEngine On

RewriteCond %{HTTPS} off

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

RewriteBase /

RewriteRule ^index.php$ — [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

#END WordPress

After adding this code to your htaccess section, our redirect will be valid.

However, these operations alone will not be sufficient. If we have manually defined http:// domains in our system, an unsecured warning appears in the URL section. When we change our http:// domains to https://, our problem will be gone.

Top comments (0)