# URI for testing web redirect

**URL:** <https://forum.ansible.com/t/uri-for-testing-web-redirect/27024>\
**Category:** Ansible Project\
**Created:** [March 17, 2018, 5:57pm UTC](https://forum.ansible.com/t/uri-for-testing-web-redirect/27024 "2018-03-17T17:57:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trg.achilles](https://avatars.discourse-cdn.com/v4/letter/t/f4b2a3/32.png) [@trg.achilles](https://forum.ansible.com/u/trg.achilles)\
**Post date:** [March 17, 2018, 5:57pm UTC](https://forum.ansible.com/t/uri-for-testing-web-redirect/27024/1 "2018-03-17T17:57:23Z")

</div>

hello,

I want to test if web redirect works first without making public. curl equivalent would be

`curl -LI --header 'Host: www.example.com' 'http://localhost'`

uri module seems to be perfect for this but struggle with headers parameter for ‘Host’ header.

Task created

`

- name: Test redirect  
uri:  
url: [http://localhost](http://localhost)  
method: GET  
headers:  
Host: “[www.example.com](http://www.example.com)”  
status\_code: 200,301,302  
follow\_redirects: all  
timeout: 10  
register: webpage  
`

and this is error message I receive:

`fatal: [ansible]: FAILED! => {"cache_control": "no-cache,no-store", "changed": false, "connection": "close", "content": "Error: Bad request. Hostname in the Host header is not sa", "content_length": "57", "content_type": "text/html", "msg": "Status code was not [200, 301, 302]: HTTP Error 400: Bad Rquest", "pragma": "no-cache", "redirected": false, "status": 400, "url": "http://127.0.0.1"}`

Obviously something not right with header but also not sure about url. Any hint would be greatly appreciated. I could do work around by creating temporary record in /etc/hosts but really would like to try the more elegant way if possible.
