Title: wp_remote_get , headers referer?
Last modified: January 24, 2017

---

# wp_remote_get , headers referer?

 *  [Rado](https://wordpress.org/support/users/jeriksson/)
 * (@jeriksson)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/wp_remote_get-headers-referer/)
 * Hello,
 * Can anyone explain why this is not working?
 * wp_remote_get($imageUrl, array(‘timeout’ => 15, ‘headers’ => array(‘referer’ 
   => ‘[http://mydomain.net&#8217](http://mydomain.net&#8217);))));
 * the referer does not change, am i doing it wrong?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [irfanahmad7272](https://wordpress.org/support/users/irfanahmad7272/)
 * (@irfanahmad7272)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/wp_remote_get-headers-referer/#post-8697195)
 * Here is working example
 *     ```
       $response = wp_remote_get( 'https://wordpress.org' );
       if( is_array($response) ) {
           var_dump($response);exit;
       }
       ```
   
 * check documentation here
    [https://codex.wordpress.org/Function_Reference/wp_remote_get](https://codex.wordpress.org/Function_Reference/wp_remote_get)
 *  Thread Starter [Rado](https://wordpress.org/support/users/jeriksson/)
 * (@jeriksson)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/wp_remote_get-headers-referer/#post-8697999)
 * can you give a working example using the second example instead as in:
 * `wp_remote_get( 'http://www.example.com/index.php?action=foo', array( 'timeout'
   => 120, 'httpversion' => '1.1' ) );`
 * but with headers included instead?
 * My logic makes me think that this would work:
 * `wp_remote_get( 'http://www.example.com/index.php?action=foo', array( 'timeout'
   => 120, 'headers' => 'http://mydomain.com' ) );`
 * but it doesn’t.
 * What am i doing wrong?
    -  This reply was modified 9 years, 4 months ago by [Rado](https://wordpress.org/support/users/jeriksson/).
    -  This reply was modified 9 years, 4 months ago by [Rado](https://wordpress.org/support/users/jeriksson/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/wp_remote_get-headers-referer/#post-8698373)
 * I believe the value of the headers argument needs to be a complete header string
   as one might supply for a call to headers(), like so:
    `'headers' => 'Referer:
   http://mydomain.com',`
 * If you have several headers to send, assign an array of string values, each element
   formatted as in my example. Also note that the Referer: header, as is tradition,
   is intentionally misspelled. “Referrer” is proper English.
 * Untested though. If you still have trouble let me know and I’ll dig deeper.
 *  Thread Starter [Rado](https://wordpress.org/support/users/jeriksson/)
 * (@jeriksson)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/wp_remote_get-headers-referer/#post-8698437)
 * thanks, but i can’t get it to work.
 * `wp_remote_get($imageUrl, array('headers' => 'Referer: http://mydomain.com')));`
 * $imageurl is the url to the image.
 * i’m not quiet sure if it’s the header not being sent of some other issue, the
   origin of the issue started when a client requested that images that were hosted
   on his gallery would not to be visited directly, so i added some stuff to an 
   htaccess file where the images reside:
 *     ```
       RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com.*$ [NC]  
       RewriteRule \.(jpg|jpeg|png|gif)$ / [L]
       ```
   
 * which works perfectly as it should, when someone tries to visit [http://mydomain.com/gallery/1.jpg](http://mydomain.com/gallery/1.jpg)
   they get a 404 , but if you visit [http://mydomain.com](http://mydomain.com) 
   and [http://mydomain.com/gallery/1.jpg](http://mydomain.com/gallery/1.jpg) is
   linked on the page it will find the image as the referer header sent contains
   the mydomain.com.
 * The issue is the client is also using a plugin which uses the function wp_remote_get
   when you publish a new post and it grabs the first image it finds in the post
   body automatically and attaches it as a thumbnail to the post. This is what am
   in trying to get to work here, but even if i add the referer header it will not
   work, it works instantly if i remove the htaccess code.
 * Any ideas?
    -  This reply was modified 9 years, 4 months ago by [Rado](https://wordpress.org/support/users/jeriksson/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘wp_remote_get , headers referer?’ is closed to new replies.

## Tags

 * [wp_remote_get](https://wordpress.org/support/topic-tag/wp_remote_get/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 3 participants
 * Last reply from: [Rado](https://wordpress.org/support/users/jeriksson/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/wp_remote_get-headers-referer/#post-8698437)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
