user3476168
user3476168

Reputation: 280

Htaccess redirect https to http for all pages except homepage, redirect https for homepage to another url

I am trying to redirect all https request to http excluding the homepage but i also want the https request for homepage to redirect to another url.

here is what i have in my .htaccess right now

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

the rule above redirects everything except homepage but i want the homepage redirected to another url e.g

https://www.example.com/ 
redirects to
http://www.example.com/non-secured-page

i need a full .htaccess rule that can do this.

Upvotes: 3

Views: 835

Answers (1)

anubhava
anubhava

Reputation: 785128

You can use:

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteRule (.+) http://www.example.com/$1 [R=301,L,NE]

RewriteCond %{HTTPS} on
RewriteRule ^/?$ http://www.example.com/non-secured-page [R=301,L]

Upvotes: 1

Related Questions