---
title: "How to Force HTTP or HTTPS using .htaccess and WP-Config"
description: "# How to Force HTTP or HTTPS using .htaccess and WP-Config When installing an SSL certificate your website is now available in HTTP and HTTPS (Secure). It is usually best to redirect all HTTP links to HTTPS as these are…"
url: "https://staging2.conorbradley.co.uk/kb/force-http-or-https-using-htaccess-and-wp-config/"
updated: "2026-01-28"
category: Popular Articles
tags:
  - Forcing HTTP
---

# How to Force HTTP or HTTPS using .htaccess and WP-Config

# How to Force HTTP or HTTPS using .htaccess and WP-Config

When installing an SSL certificate your website is now available in HTTP and HTTPS (Secure). It is usually best to redirect all HTTP links to HTTPS as these are encrypted and secures your website’s data.

## Force HTTPS on All Traffic

To force HTTPS on all traffic you'll need to create or edit the **.htaccess** file. This is located in your file manager inside the public HTML folder. If you cant see the file head to the top, right of the screen and press the settings box then click show hidden files (dotfiles).

1. Open your **File Manager **in your hosting panel and open **.htaccess **inside the **public_html **folder. \*If you've enabled hidden files and you still can't see it go to the top, left corner and click +File and name it .htaccess.
2. Find **RewriteEngine On** and type/paste the following lines of code below it:
3. **RewriteEngine On**
   **RewriteCond %{HTTPS} off**
   **RewriteRule ^(.\*)$ https://%{HTTP_HOST}%{REQUEST_URI} \[L,R=301\]**
4. **Save** the changes.

 \*Make sure that the line **RewriteEngine On** is not repeated twice.

 

## Force HTTPS on a Certain Domain

If you have two domain names that go to the same website but you're wanting only one of the domain names to redirect to HTTPS. follow the steps and change conorbradley.co.uk to your domain name:

1. **RewriteEngine On**
   **RewriteCond %{HTTP_HOST} ^ conorbradley.co.uk \[NC\]**
   **RewriteCond %{HTTPS} off**
   **RewriteRule ^(.\*)$ https://%{HTTP_HOST}%{REQUEST_URI} \[R=301,L\]**

. \*Make sure that the line **RewriteEngine On** is not repeated twice.

## Force HTTPS on a Specific Folder

You can also edit the **.htaccess **file to force HTTPS on specific folders. The folder you're enabling must be placed in a location that enables HTTPS connection.

1. **RewriteEngine On**
   **RewriteCond %{HTTPS} off**
   **RewriteRule ^(images|videos|pages) https://%{HTTP_HOST}%{REQUEST_URI} \[R=301,L\]**

Make sure to change the images|videos|pages references to the directory names you have in your file manager as this is an example.

Please clear your browser's cache after making the updates you can do this by following [our guide.](https://staging2.conorbradley.co.uk/kb/clear-dns-cache-on-your-computer/)

 

## Forcing HTTP on a WordPress Site

When creating a new website, sometimes on a subdomain can get stuck using HTTPS as their domain is forced to use SSL. Your new WordPress site needs to sync to their SSL certificate which can take up to 24 hours. If you're wanting to edit your site straight away follow these steps:

1. Open your hosting **file manager > public_html > then find wp-config.php**
2. Just before the **"/\* That's all, stop editing! Happy publishing. \*/"** paste the following
3. define('WP_HOME','http://domain.conorbradley.co.uk');
   define('WP_SITEURL','http://domain.conorbradley.co.uk');
4. make sure you change http://domain.conorbradley.co.uk to your domain name.

\*You can also change the HTTP to HTTP when your SSL certificate starts working. This can be checked through AutoSSL in C-Panel if your hosting provider supports this.

 

 

                                             [Facebook](https://www.facebook.com/conorbradleydigitalagency) | [Twitter](https://twitter.com/ConorAgency) | [Instagram](https://instagram.com/conorbradleydigitalagency) | [Youtube](https://youtube.com/conorbradleydigitalagency) | [Vimeo](https://vimeo.com/conorbradleyagency) | [Blog](https://staging2.conorbradley.co.uk/blog/) | [Knowledge Base](https://staging2.conorbradley.co.uk/kb/)
