Nabsdar
asked on
Redirect to HTTPS
Hello,
How can I configure IIS 5 to redirect a website (virtual directory) to a secured site? When users type http://www.website.com/website they get an error and I have to tell them to insert a 's' in after the http(s) to make it viewable. Basically I want to configure IIS to automatically redirect them when they type http://www.website.com/website to https://www.website.com/website? Can someone please assist me?
Thanks in advance
Nabs
How can I configure IIS 5 to redirect a website (virtual directory) to a secured site? When users type http://www.website.com/website they get an error and I have to tell them to insert a 's' in after the http(s) to make it viewable. Basically I want to configure IIS to automatically redirect them when they type http://www.website.com/website to https://www.website.com/website? Can someone please assist me?
Thanks in advance
Nabs
ASKER
Thanks for your prompt input but is this not going to effect the entire website? I am just looking for redirection on a virtual directory http://www.website.com/virtual_directory.com to an https. Please advice
Thanks again,
Nabs
Thanks again,
Nabs
Other things might be set your virtual home directory properties, instead to specific folder, make it to specific url:
https://www.website.com/virtual_directory
https://www.website.com/virtual_directory
ASKER
This solution is not working very well for me! Any other ideas anyone?
Thanks
Nabs
Thanks
Nabs
Simpler solution:
1. Create one html page, name it redirectssl.htm and save it into your virtual directory folder. Here is the redirectssl.htm content:
<script language=javascript>
self.location = "https://www.website.com/virtual_directory.com "
</script>
<noscript>
<META HTTP-EQUIV=Refresh CONTENT="1; URL=https://www.website.com/virtual_directory.com ">
</noscript>
2. Open your IIS, right click on your virtual directory site, click Properties.
3. Switch to Custom Error Tab
4. Edit properties of 403;4.
5. Set message type to FILE
6. Click browse button and point it into your redirectssl.htm
7. Click OK button twice.
Now try to put http://www.website.com/virtual_directory.com (without s).
HTH.
1. Create one html page, name it redirectssl.htm and save it into your virtual directory folder. Here is the redirectssl.htm content:
<script language=javascript>
self.location = "https://www.website.com/virtual_directory.com "
</script>
<noscript>
<META HTTP-EQUIV=Refresh CONTENT="1; URL=https://www.website.com/virtual_directory.com ">
</noscript>
2. Open your IIS, right click on your virtual directory site, click Properties.
3. Switch to Custom Error Tab
4. Edit properties of 403;4.
5. Set message type to FILE
6. Click browse button and point it into your redirectssl.htm
7. Click OK button twice.
Now try to put http://www.website.com/virtual_directory.com (without s).
HTH.
You need something similar to Apache's Rewrite....
http://www.isapirewrite.com/
This tool will let your server redirect URLs based on various criteria.
ShalomC
http://www.isapirewrite.com/
This tool will let your server redirect URLs based on various criteria.
ShalomC
ASKER
Hello daniel_c
You are definitely on the right track with the last solution to my problem but it still does not work! Please advice further.
Thanks for your time,
Nabs
You are definitely on the right track with the last solution to my problem but it still does not work! Please advice further.
Thanks for your time,
Nabs
it does not work? you mean it doesn't redirect?
ASKER
Yes, it does not redirect.
Post your HTML file code. I need to see it.
ASKER
Okay it worked!
I had put in the wrong code!
Thanks daniel_c: so now to apply this to our current directory, should I just insert this code in it or how do I go about this?
I really appreciate your help
Nabs
I had put in the wrong code!
Thanks daniel_c: so now to apply this to our current directory, should I just insert this code in it or how do I go about this?
I really appreciate your help
Nabs
ASKER
One other problem:
I don't see the contents of the page. It redirects it to https but its just a page with an error!
Why?
I don't see the contents of the page. It redirects it to https but its just a page with an error!
Why?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Each website has a default document, the redirect should be named that (I.E. default.htm)
The target website has a document you want people to load, so specify it in the code.
---
script language=javascript>
self.location = "https://www.website.com/virtual_directory/HTMLfileNAME.HTM "
</script>
---
The target website has a document you want people to load, so specify it in the code.
---
script language=javascript>
self.location = "https://www.website.com/virtual_directory/HTMLfileNAME.HTM "
</script>
---
ASKER
Thanks daniel_c fir putting me on the right direction. I finally got it to work perfectly!!
Nabs
Nabs
Great!!!
We use an SSL accerlerator so ASP doesn't see the request as HTTPS. I came up with the code below to perform the redirect using JavaScript since the client always sees the request as SSL.
<SCRIPT LANGUAGE="JavaScript">
if (location.protocol != 'https:'){
window.location= 'https://' + location.host + location.pathname + location.search
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
if (location.protocol != 'https:'){
window.location= 'https://' + location.host + location.pathname + location.search
}
</SCRIPT>
Just wanted to post my solution.
Basicaly same as above by Daniel
1. Open your IIS, right click on your virtual directory site, click Properties.
2. Switch to Custom Error Tab
3. Edit properties of 403;4.
4. Set message type to FILE
5. Click browse button and point it into your redirect.htm
6. Click OK button twice.
redirect.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>API E-MAIL SERVER</title>
<meta http-equiv="REFRESH" content="1;url=https://site/exchange"></HEAD>
<BODY>
Loading... https://site/exchange
</BODY>
</HTML>
note:
content="1 - is the time in seconds it will take to redirect
Basicaly same as above by Daniel
1. Open your IIS, right click on your virtual directory site, click Properties.
2. Switch to Custom Error Tab
3. Edit properties of 403;4.
4. Set message type to FILE
5. Click browse button and point it into your redirect.htm
6. Click OK button twice.
redirect.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>API E-MAIL SERVER</title>
<meta http-equiv="REFRESH" content="1;url=https://site/exchange"></HEAD>
<BODY>
Loading... https://site/exchange
</BODY>
</HTML>
note:
content="1 - is the time in seconds it will take to redirect
Another (and perhaps better) way is to have two websites - one that accepts host headers for mysite.com, .org, .net and whatever else you want. Everything is on port 80. In the Home Directory tab in IIS manager, set it to "A redirection to a URL". Enter https://mysite.com. Also check the permanent redirect box.
Next, in the site you want to force SSL, make sure it also responds to the mysite.com host header, but change the port to something high - make sure its unreachable behind your firewall. Set the security as necessary and you're done.
Next, in the site you want to force SSL, make sure it also responds to the mysite.com host header, but change the port to something high - make sure its unreachable behind your firewall. Set the security as necessary and you're done.
I have to agree with dmbrubac (for IIS, anyway). Changing the 403;4 error page to a redirect will send you to the the same page every time. If you have hyperlinks from other websites that point to subdirectories within the domain, the hyperlinks will not go where expected, instead they will always point to the URL in the redirect--forcing the unsuspecting user to re-navigate to the desired page once they arrive.
With two websites (on IIS), you can set the redirect from the port 80 site to https://mysite.com$S$Q, which will act as expected and send the user to the desired subdirectory every time.
With two websites (on IIS), you can set the redirect from the port 80 site to https://mysite.com$S$Q, which will act as expected and send the user to the desired subdirectory every time.
<%
bSSLOn = (Request.ServerVariables("
if not bSSLOn then
sURL = "https://" & Request.ServerVariables("S
if Request.ServerVariables("Q
sURL = sURL & "?" & Request.ServerVariables("Q
end if
Response.Redirect sURL
end if
%>
HTH.