Andrew Andrew - 1 year ago 126
Apache Configuration Question

.htaccess rewrite condition to redirect links from http to https

I have a lot of different links without any logical rules, that are redirected with .htaccess

Redirect 301

.htaccess looks like this:

<IfModule mod_rewrite.c>

RewriteCond %{HTTP_HOST} ^

Redirect 301 /oldlink1 /newlink1
Redirect 301 /oldlink1 /newlink1
Redirect 301 /oldlink1 /newlink1


Some days ago I've set up https. Unfortunately,
redirects to
- not to https but http.

What i'm doing wrong? How should I set up .htaccess file to redirect to https?

Answer Source

If you're changing protocols or sites, then you HAVE to use an absolute url:

Redirect 301 /oldlink

otherwise it's just a "local" redirect and you stay within the same site/protocol.

And note that Redirect is NOT part of mod_rewrite. That's a core directive in Apache (part of mod_alias) and has nothing to do with mod_rewrite at all:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download