0

I tried some help from other topics on this site but I faced the redirect loop error.

My current htaccess code:-

RewriteEngine on

RewriteCond %{SERVER_PORT} ^80$

RewriteCond %{HTTP_HOST} !^www\.

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^([^.]+)/?$ index.php?v=$1 [QSA,L]

RewriteEngine on

RewriteCond %{SERVER_PORT} ^443$

RewriteCond %{HTTP_HOST} !^www\.

RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^([^.]+)/?$ index.php\?v=$1 [QSA,L]

The above is not related to this question but to get a proper help from you, I have included it.

Now I want to redirect all https urls to http except two /login/ and /register/

How can I ensuring to use the minimum conditions.

user38181
  • 3
  • 1

1 Answers1

0

Unless you are wedded to using .htaccess, you could at the top of the pages you want to go to http check with PHP and use a header location to send them to http.

if($_SERVER['SERVER_PORT'] == 443)
    header('Location: http://'.$_SERVER['HTTP_HOST'].'/'.$rest_of_path);

There is some good info here on how to construct the whole url so they go to the same page. Getting the full URL of the current page (PHP)

Community
  • 1
  • 1
dmgig
  • 4,400
  • 5
  • 36
  • 47