-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support S3 server-side redirects #14
Comments
This is actually quite interesting @tomdyson thanks! Although you force the user to use S3 (it's an option now). I'll contact the guys from |
Yeah, we rolled our own for use with Wagtail... def create_s3_redirects(self):
self.stdout.write('Creating redirects')
site = Site.objects.filter(is_default_site=True).first()
redirects = Redirect.objects.all()
for r in redirects:
old_path = r.old_path[1:] # strip leading /
self.stdout.write(old_path)
dest_url = r.redirect_link
if r.redirect_page:
dest_url = r.redirect_page.specific.relative_url(
r.site or site
)
dest_url = settings.BASE_URL + dest_url
self.create_s3_redirect(old_path, dest_url)
def create_s3_redirect(self, old_path, dest_url):
self.s3.meta.client.put_object(Bucket=settings.AWS_STORAGE_BUCKET_NAME,
Key=old_path,
WebsiteRedirectLocation=dest_url) So if you implement the adapter idea, there'd be a method to create redirects and those backends that couldn't do redirects could just stub it out. |
Awesome @dprothero. However support for Redirects is missing now actually in this module. A separate |
http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
Just an idea :)
The text was updated successfully, but these errors were encountered: