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

user3476168

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.

anubhava

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]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

.htaccess redirect all pages to homepage except few of them

Magento HTTPS on all website: urls redirect to homepage

301 redirect for index.html and all http,https, www and non-www version of homepage URL to https://www root url via htaccess

.htaccess - 301 redirect move all pages to https:// - except 1 page?

.htaccess, redirect to https of http url

.htaccess redirect to https except admin url

Htaccess redirect https to another https

.htaccess redirect http to https

iis rewrite redirect all pages to homepage

htaccess redirect HTTP_USER_AGENT but not the homepage

.htaccess redirect only homepage, not when parameter in URL

.htaccess https only for homepage and http for other

CakePHP Homepage URL Redirect

How to redirect entire domain to new domain except homepage via htaccess

HTTP to HTTPS redirect not working with .htaccess

Use .htaccess to redirect HTTP to HTTPs

HTTP to HTTPS redirect issue .htaccess

Redirect HTTP to HTTPS using htaccess?

htaccess redirect to HTTPS except a few urls

nginx redirect 301 all pages to another domain / homepage add query string

How to redirect all HTTPS to HTTP

WordPress redirect all HTTPS to HTTP

Redirect HTTP to HTTPS for ALL Subdomains

.htaccess redirect all http to https and one the other way

ddev / TYPO3 / .htaccess - redirect all http -> https

Using .htaccess redirect all files/directories to a subdirectory but exclude the homepage

.htaccess RewriteRule to redirect http to https messes up % escaped parameters in URL

url-masking redirect http to https using .htaccess

.htaccess: redirect all pages except one not working