Cruclax
Cruclax

Reputation: 414

How to do URL masking with Django?

On a Django 1.9 project I need to redirect:

https://example.com/app/

to

https://examplebucket.s3.amazonaws.com/app/index.html

But I need https://examplce.com/app/ to be still visible on the browser address bar...

I know this must be possible in theory with Django because the previous team working on this project did a setup to serve the /static/ media files from an S3 bucket. And if I access those static files via https://example.com/static/app/index.html, they are served from the S3 bucket but the browser address bar still shows the original url I input.

I'm deploying an Ionic Browser project and I want the files (including the index) to be served from the S3 but the url needs to be user friendly, thats the reason.

Upvotes: 1

Views: 1387

Answers (1)

rtpHarry
rtpHarry

Reputation: 13125

The old (dirty) way of doing this is frame-based forwarding.

You set up an iframe on a page in /app/ which points at the real app, letting the url stay the same.

It's not considered a good practice because of security issues (can't be sure where you are typing credentials into), and bookmarking issues (url is always the same so can't bookmark inner pages).

Another alternative is to set up a proxy script that just takes the url, turns that into the equivalent aws url, downloads it and then returns it. This would break the benefits of your cloud hosting if it has multiple regions... it would always be passed through the bottleneck of your server.

Upvotes: 2

Related Questions