# Redirection with https

**URL:** <https://discourse.haproxy.org/t/redirection-with-https/1693>\
**Category:** Help!\
**Created:** [October 19, 2017, 10:12am UTC](https://discourse.haproxy.org/t/redirection-with-https/1693 "2017-10-19T10:12:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wilnzi](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@wilnzi](https://discourse.haproxy.org/u/wilnzi)\
**Post date:** [October 19, 2017, 10:12am UTC](https://discourse.haproxy.org/t/redirection-with-https/1693/1 "2017-10-19T10:12:55Z")

</div>

Hi,  
Helps please.

I’m trying to configure redirection.  
I would like to do that :

if client enters [https://example.com](https://example.com) it will be redirect to https:://www.site.com

My configuration is :  
redirect prefix [https://www.site.cm](https://www.site.cm) if { hdr(host) -i [example.com](http://example.com) }

But when the user enters [https://example.com](https://example.com) it’s redirect to the root folder.

How can i correct this issue ?

Thanks in advance !!

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [October 19, 2017, 10:51am UTC](https://discourse.haproxy.org/t/redirection-with-https/1693/2 "2017-10-19T10:51:44Z")

</div>

Share your complete configuration please?

---

<div class="post-metadata">

**Author:** ![wilnzi](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@wilnzi](https://discourse.haproxy.org/u/wilnzi)\
**Post date:** [October 19, 2017, 4:29pm UTC](https://discourse.haproxy.org/t/redirection-with-https/1693/3 "2017-10-19T16:29:33Z")

</div>

My configuration

global  
log /dev/log local0  
log /dev/log local1 notice  
chroot /var/lib/haproxy  
stats socket /run/haproxy/admin.sock mode 660 level admin  
stats timeout 30s  
user haproxy  
group haproxy  
daemon

```
tune.ssl.default-dh-param 2048
maxconn 5000

# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3

```

defaults  
log global  
mode http  
option forwardfor  
option http-server-close  
option httplog  
option dontlognull  
timeout connect 5000  
timeout client 50000  
timeout server 50000  
errorfile 400 /etc/haproxy/errors/400.http  
errorfile 403 /etc/haproxy/errors/403.http  
errorfile 408 /etc/haproxy/errors/408.http  
errorfile 500 /etc/haproxy/errors/500.http  
errorfile 502 /etc/haproxy/errors/502.http  
errorfile 503 /etc/haproxy/errors/503.http  
errorfile 504 /etc/haproxy/errors/504.http

frontend www-http  
bind \*:80  
mode http  
option httpclose  
option forwardfor

```
redirect prefix https://www.site.cm if { hdr(host) -i www.example.com }
redirect prefix https://www.site.cm if { hdr(host) -i example.com }

```

frontend www-https  
bind \*:443 ssl crt /key.pem  
mode http  
option forwardfor  
option httpclose  
option http-server-close  
reqadd X-Forwarded-Proto:\ https

```
redirect prefix https://www.site.cm if { hdr(host) -i www.example.com }
redirect prefix https://www.site.cm if { hdr(host) -i example.com }
 
 

default_backend defaultBackendServer

```

backend defaultBackendServer  
mode http  
redirect scheme http code 301 if !{ ssl\_fc }  
balance source  
server SRV-WEB-1 192.168.2.13:80 check  
server SRV-WEB-2 192.168.2.14:80 check

backend testBackend

```
mode http 
redirect scheme http code 301 if !{ ssl_fc }
balance source
acl no_redir url_beg /test/test/
reqirep ^([^\ :]*)\ /(.*) \1\ /test/test/\2 if !no_redir
server SRV-WEB-1 192.168.2.13:80 check
server SRV-WEB-2 192.168.2.14:80 check

```

listen stats  
bind 192.168.2.16:1992  
mode http  
log global  
maxconn 2  
clitimeout 100s  
srvtimeout 100s  
contimeout 100s  
timeout queue 100s  
stats enable  
stats hide-version  
stats refresh 30s  
stats show-node  
stats auth admin:password  
stats uri /haproxy?stats

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [October 19, 2017, 5:40pm UTC](https://discourse.haproxy.org/t/redirection-with-https/1693/4 "2017-10-19T17:40:23Z")

</div>

I don’t see anything wrong with this configuration.

What do you see from a curl output?

```
curl -vv http://example.com
curl -vv http://www.example.com
```
