Losing query string on redirect from https to http - asp.net

I have a site https:// www.mysite.com that runs completely using HTTPS (I redirect http to https in IIS). This all works fine.
I have an old version of the site http:// old.mysite.com which some users are still running on that is running over HTTP only. This all works fine.
There is 1 URL that my new site redirects (using a Response.Redirect in the global.asax) to my old site. For example the user requests https:// www.mysite.com/page.aspx?query=string and I redirect them to the old site http:// old.mysite.com/page.aspx?query=string. The redirect works well except that the query string is missing when it gets to the old site.
The URL that I have to redirect comes from a url embedded at customer sites, so I can't just update them all to point to the old site. I tested and this all works fine when I run my new site under HTTP so the transfer is HTTP to HTTP, but it fails when I do HTTPS to HTTP.
Any ideas on what the problem is?
Thanks,
Jim

Alright I got it figured out so I'll post in case anyone else hits the issue. I was using the HTTP Redirect module in IIS 7 to redirect any HTTP traffic to HTTPS for my new website. For the url to redirect to I just had 'https://www.mysite.com'. I found some variables that you can add to the redirect url to keep the query string. So once I updated it to 'https://www.mysite.com$S$Q' it worked.

Related

Redirection on nginx from URL https://www.domian.io to https://domain.io

I have a site for which I want to redirect from the subdomain www.domain.io to domain.io.
From http it works very well, but when I try to access the site with https before it, that is https://www.domain.io, the redirection does not take place.
I want the redirection to work on https as well as on http.
Error appears only on Firefox. On other browsers it works perfectly.
https://www.domain.io do not redirect to https://domain.io
The received error looks like this image
Can someone help me?

Tomcat app http to https redirect displays ROOT in URL

Context path is set to ROOT in tomcat app because I want to access the URL without any path ex: https://URL/. AWS Loadbalancer just redirects to the app servers. It works if I directly access https site. But if I access http site, the http to https redirect takes to https://URL/ROOT and displays "page not found", then I'd to remove the ROOT to access the page. If any path is set in the context i.e https://URL/PATH/, the redirection works good but only if ROOT, http redirection is having this issue. I guess context.xml, web.xml, server.xml looks good to me. Obviously needs some tweak. Any help is appreciated please.
http listener rules had ROOT instead of default {path} hence why redirection happened. Right now it is fixed and I don't see ROOT in the http URL redirecting to https.

Disable https for a specific page with a 301 redirection

I have a website running with https on all pages. I would like to make a 301 redirection for a specific page to make it available only with http (not https).
This is my code :
Redirect 301 https://www.example.com/a-page http://www.example.com/a-page
This does not work, i run a Wordpress website. How to make it runs with a simple way ?
Thanks
What do your .htaccess do to HTTP/HTTPS?
Are you forcing all users to use HTTPS?
Because you can make both be usable depending on how you want your server to handle the requests and what the browser user has requested.

cannot update IIS 7 site redirect rule

I have two web applications, let's call them foo.com and www.foo.com.
The client asked me to 301 redirect all requests from foo.com to www.foo.com.
So what I did was select foo.com in IIS manager and in the HTTP Redirect settings, added a redirect to www.foo.com:
Problem is, it now redirects infinitely to http://foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com/www.foo.com until max URL Length has been reached and throws an error.
I went back and edited to destination to http://www.foo.com because I thought it was treating it as a relative redirect because I left off the "http://":
but it seems as though my first settings are being cached because no matter what I change the redirect destination to (a random URL, a word, etc), it always redirects endlessly to the same URL mentioned earlier. It's like it is cached inside of IIS and I don't know where or how to update the destination. Any ideas?

How to check if an HTTPS URL redirects to an HTTP URL?

I have a list of HTTPS URLs and I want to make sure they are accessible. I use HttpURLConnection to follow redirects by checking for any 300/301/302 responses, following the redirect, and so on until I get a 200 or anything else.
How do I check along the way that none of the redirects are to a HTTP (non-secure) endpoint?
Does it ever fail if the redirect from an HTTPS goes to HTTP, or do I have to manually check?
HttpURLConnection won't follow redirects when switching protocol (http -> https, https -> http). So you'll know when such redirects happen. If you want to be 100% safe, call
HttpURLConnection.setFollowRedirects(false) or
conn.setInstanceFollowRedirects(false).

Resources