Referrer Spoofing in Django - django

I have been searching internet for some good docs/articles on how to implement referrer spoofing using django or django templates.
The project that we are working right now is a dynamic website, where in we get results from mysql database based on the search done by the user.
I am not getting any idea of how to implement this or know of any packages to do this.
Example:
If the original url in mysql database is http://www.google.com and my website is www.example.com.
The link that I should show is www.example.com/redirect/dfjldfjlsdf which will redirect to google.
Note: I am not posting any code/or what I tried because I am not getting any ideas on how to implement this.
Please help me.

I wrote a redirection script. The steps are:
Setup some url handler.
Setup a view for this handler.
Setup a meta refresh html template.
Metarefresh template will blank the referrer before sending the end user to the target url.
If you want to get an idea, follow this question and the accepted answer: django get complete url in query string

Related

Redirecting old urls to new urls in Django

After publishing site in Django, I changed my slugs and now old pages show as errors in Google search. Is there a way to automatically redirect them without having to write an individual redirect for each page?
There are a few things you need to do to make sure that your website gets crawled properly.
In regards to the redirection, you can use django.http.HttpResponsePermanentRedirect to perform the redirection. Just keep the view, and when a user navigates to this view, redirect them to the proper URL.
You should also create a sitemap, which lists out all of the URLs for your website. You can then submit this sitemap to google using their webmaster tool if you have not already done so. This will inform their crawler of all the pages that they need to crawl without worrying on them missing some information

django redirect to subdomain with exact same url

I have a Django website accessible at codewithbishal.com. This is basically a django blog website and all the blog articles are accessible at codewithbishal.com/example/<path>
But now I want to completely restructure the website{such that it is accessible at blog.codewithbishal.com/<path>} and I do no want to lose the current SEO therefore I want to configure django redirect such that when someone launches codewithbishal.com/example/<path> through google search search result or directly through link, they are redirected to blog.codewithbishal.com/<path> instead of a 404 page and eventually google will start showing the new links instead of old once.
Update: Should I configure redirect through apache .htaccess?
You can use the Django redirects app. Just click the link and find the guide.

Django Twitter callback goes to IP-address, not domain

I suddenly got a problem with the twitter redirect going to the IP-adress of my site, not the actual domain, after authorization. This has been working as expected before.
I am using Django for my project, and the IP-adress is in the ALLOWED_HOSTS list. The twitter application itself is correctly figured with the domain, not any IP-adress, it just "chooses" to use the IP, it seems.
Have I misconfigured something server-side maybe? Im a bit of a Django newbie.
Thanks for any suggestions.

keep media in base URL

So, I am looking for a solution to have images through the base website URL.
Example of image url:
www.website.com/image.jpg
Where the homepage lives at the url:
www.website.com/
I am using the django python web framework, and am aware this is a peculiar, if not just bad idea, but my client has linked several hundred images to their base URL in the above format, and refuses to change the existing links.
I know this is a vague question, but I can't seem to find anything relevant. Do I just set the media url to the same as the website?
Why don't you just configure your web server to rewrite the paths?
You could also configure it using an alternate host, assets.example.com for example and serve everything from there. Then you could rewrite all requests going at www.website.com to assets.example.com.

Iframe working correctly on localserver but not production server

A question like this was asked before and the person got nothing but criticisms, hope this won't be the case here.
I have a website that allows a business to add their menu to my site, and some have requested to be able to import a menu (a pdf or jpg) that is already online elsewhere. So I made a form that saves a url to the db and then that url is used in the src of an iframe on my site.
I tested it all and it worked fine on my local machine (using Django development server). When I synced it over to my production server and saved the same url I was testing with, the iframe loads no content.
I imagine that it has something to do with trying to read an individual file from another server because it works if I make the url google.com or to an image that is under my domain name. Is there anything I can do to fix this? Storing a url instead of a pdf in my db is much more efficient so doing this way is preferred over uploading their menu to my site.
I don't think this question needs any code attached, but if you want to see some let me hear it.
Thanks
The menu you're testing with probably has the X-Frame-Options response header set.
Is there a reason you're putting the image/pdf as the src on an iframe instead of just using the img tag (or putting an img tag inside your iframe)? There's still no guarantee that will work for all pages, as some sites will refuse to serve media to an external page, but I suspect this is your problem in this case.