Web Server

Redirecting HTTP Access to HTTPS in .htaccess

This article introduces how to redirect HTTP access to HTTPS using .htaccess on an Apache server. In terms of SEO, having HTTP and SSL HTTPS mixed is very bad. In Search Console, when you change to SSL, you need to register the site anew.

Shou Arisaka
1 min read
Nov 13, 2025

This article introduces how to redirect HTTP access to HTTPS using .htaccess on an Apache server.

In terms of SEO, having HTTP and SSL HTTPS mixed is very bad. In Search Console, when you change to SSL, you need to register the site anew.

When accessing http://example.com/dev/, by making it as if https://example.com/dev/ was accessed, you can enhance SEO effects. To achieve this, apply a permanent redirect to the entire site using .htaccess.


# BEGIN WordPress
<IfModule mod_rewrite.c>

# added code to redirect http to https
# =======

RewriteEngine On
RewriteBase /

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

# =======

RewriteEngine On
RewriteBase /dev/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/index.php [L]
</IfModule>

# END WordPress

The following part redirects http to https.

RewriteEngine On
RewriteBase /

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

Share this article

Shou Arisaka Nov 13, 2025

๐Ÿ”— Copy Links