Title: Redirection with referer header
Last modified: August 22, 2023

---

# Redirection with referer header

 *  [luizargument](https://wordpress.org/support/users/luizargument/)
 * (@luizargument)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/redirection-with-referer-header/)
 * Is it possible to make a redirection from the attachment URL media to S3 sending
   a referer header?
 * Example: In my Media Library i can see a link that points directly to the media
   auto-generated page ([https://mysite.com/attachment/myimage/](https://mysite.com/attachment/myimage/))
 * With WP Offload Media, instead opening wordpress website with the image, this
   will do a “301 redirect” to [https://s3.sa-east-1.mybucket.com/mymedia/myimage.jpg](https://s3.sa-east-1.mybucket.com/mymedia/myimage.jpg),
   for example.
 * The redirection from ([https://mysite.com/attachment/myimage/](https://mysite.com/attachment/myimage/))
   to ([https://s3.sa-east-1.mybucket.com/mymedia/myimage.jpg](https://s3.sa-east-1.mybucket.com/mymedia/myimage.jpg))
   could have a referer header (Referer: [https://mysite.com/attachment/myimage/](https://mysite.com/attachment/myimage/))?
   Is it possible?

Viewing 1 replies (of 1 total)

 *  Plugin Support [Delicious Brains Support](https://wordpress.org/support/users/dbisupport/)
 * (@dbisupport)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/redirection-with-referer-header/#post-16996041)
 * Hi [@luizargument](https://wordpress.org/support/users/luizargument/) 
   WP Offload
   Media Support Team here. Thanks for reaching out with your query, we would be
   happy to assist!This is possible, but you would have to use our [Tweaks plugin](https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront-tweaks/archive/master.zip).
   Edit the [object_meta function](https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront-tweaks/blob/96d9fc03ffcfdc1d2e77b0a1a53891e6e1a76e30/amazon-s3-and-cloudfront-tweaks.php#L578)
   with something like the following – function object_meta( $args, $post_id, $image_size,
   $copy ) { $args[‘Referer’] = get_attachment_link($post_id);}Then finally, to 
   actually get WP Offload Media to start using this functionality, uncomment the`
   add_filter( 'as3cf_pre_upload_attachment', ...` line in the [__construct ](https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront-tweaks/blob/96d9fc03ffcfdc1d2e77b0a1a53891e6e1a76e30/amazon-s3-and-cloudfront-tweaks.php#L93)
   function.A few things to note are, this code is untested, have only based it 
   on the following – [https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer)
   [https://developer.wordpress.org/reference/functions/get_attachment_link/](https://developer.wordpress.org/reference/functions/get_attachment_link/)
   You may need to change it a bit for it to output the intended header.Lastly, 
   This filter would only apply to newly offload media items, as that’s the only
   time the S3 Bucket receives these headers. WP Offload Media Lite do not have 
   the capability to re-offload your Media Library items. You will either have to
   re-upload them to the media library or upgrade to the pro version.Thank you.

Viewing 1 replies (of 1 total)

The topic ‘Redirection with referer header’ is closed to new replies.

 * ![](https://ps.w.org/amazon-s3-and-cloudfront/assets/icon-256x256.jpg?rev=1809890)
 * [WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage](https://wordpress.org/plugins/amazon-s3-and-cloudfront/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amazon-s3-and-cloudfront/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/)
 * [Active Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/reviews/)

## Tags

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

 * 1 reply
 * 2 participants
 * Last reply from: [Delicious Brains Support](https://wordpress.org/support/users/dbisupport/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/redirection-with-referer-header/#post-16996041)
 * Status: not resolved