htaccess https/http redirect issue

112 views Asked by At

I am trying to use redirect links using HTACCESS for http and https.

This is my HTACCESS code:

RewriteRule ^go/(https:\/*)*(.+)$ https://$2 [L,R=301]
RewriteRule ^go/(http:\/*)*(.+)$ http://$2 [L,R=301]

When I'm using https links it works fine:

http://mywebsite.com/go/https://facebook.com 

leads to https://facebook.com

But for some reason when I use http it reads it like https and this is what happens: http://website.com/go/http://facebook.com leads to https://http/facebook.com

What am I doing wrong?

Thanks in Advance! :)

1

There are 1 answers

1
WebChemist On

Not really sure why you would want to link to external sites as fake links on your own, but ok..

you could probably condense those to 1 rule like:

RewriteRule ^go/(http(s?):/{1,2})(.+)$ http$2://$3 [R=301,L]