301 https protocol redirect to http

2

I would like to do a 301 redirect (via .htaccess) only on 1 link I have https to http without changing any other server or protocol link.

Link https: link

Redirect To: link

NOTE: Note that the link is the same only changes the https protocol to http;

Thank you!

    
asked by anonymous 20.06.2014 / 22:02

3 answers

3

For cases where everything that is HTTPS should be directed to HTTP:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
20.06.2014 / 22:30
3

Based on @Zuul's response, follow the version for your specific case,

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule blog/tag/dengue-mata/ http://meudominio.com/blog/tag/dengue-mata/ [R=301,L]

If you want to use parameters or some extra data after the bar, you can do this:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule blog/tag/dengue-mata(.*) http://meudominio.com/blog/tag/dengue-mata$1  [R=301,L]

Note that I have omitted the final slash, to contemplate URLs without the slash as well. Adjust as required.

  

Important: If your domain does not have the correct certificate, when you access it by https:// , the error message will appear before the redirect anyway. This is the nature of the protocol, which first makes the connection secure, and then requests the path.


Beware of pure redirect:

The redirect is great, but when you just change the protocol, and the path is the same, you can loop in infinite, as in this case:

Redirect 301 /blog/tag/dengue-mata/ http://meudominio.com/blog/tag/dengue-mata/
    
20.06.2014 / 22:58
0

Try this

# Permanent URL redirect
Redirect 301 /blog/tag/dengue-mata/ http://meudominio.com/blog/tag/dengue-mata/
    
20.06.2014 / 22:29