0

I have found several Q/As on how to redirect root only, how to redirect from https to http (using .htaccess). But there was no question that merged both. And this answer is too dirty: https://stackoverflow.com/questions/17952418/force-web-root-to-use-http. So I came up with an answer like the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} provectium\.com [NC]
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Is this valid? I want it so that any query to https://provectium.com/file.html will be redirected to http://provectium.com/file.html, but not the subfolders (they should remain https://provectium.com/directory/). Thank you.

P.S. I read somewhere that the second line could be RewriteCond %{HTTP_HOST} ^provectium\.com [NC], what's the role of the extra ^?

1
  • The rules you have posted above will redirect all requests to the HTTP URL. Do you want this to work for any page in the root of the site or just file.html? Sep 27, 2014 at 12:14

1 Answer 1

0

This should work for / (root) and all pages under / but not any subfolders.

RewriteEngine on
RewriteCond %{HTTP_HOST} provectium\.com [NC]
RewriteCond %{HTTPS} on
RewriteRule ^([^/]+)?$ http://%{HTTP_HOST}/$1 [R=301,L]

If you put ^ in the second line, the rule will match only if the host is exactly provectium.com and won't match www.provectium.com.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .