Solved

Redirect IIS 6 website using global.asa?

Posted on 2016-11-16
5
14 Views
Last Modified: 2016-11-21
I want to redirect non-WWW URLs on my website to WWW URLs.

Since I am on Windows with IIS 6, I can't do this with .htaccess or web.config.

I would like to do it without creating a separate website in IIS, if possible (I already know how to do redirects that way).

I have never worked with global.asa files before. This website:
http://www.developwebsites.net/redirect-pages-classic-asp/

...seems to suggest it can be done, with the following code in a global.asa file:

<%@LANGUAGE="VBSCRIPT"%>
<%
' If the domain is not www.example.com send the visitor to the correct domain with a
' 301 Moved Permanently status and append the correct page to the URL. Finally kill the
' script so that processing stops here
If (InStr(Request.ServerVariables("SERVER_NAME"),"www.example.com") = 0) then
   Response.Status = "301 Moved Permanently"
   Response.AddHeader "Location", "http://www.example.com" _
     + Request.ServerVariables("PATH_INFO")
   Response.End()
End If
%>

Open in new window


I am testing on this website:
http://lewilliamsprinting.com/

Non-WWW URLs are not redirect to WWW, despite my having added a global.asa file with the following code:

<%@LANGUAGE="VBSCRIPT"%>
<%
' If the domain is not www.example.com send the visitor to the correct domain with a
' 301 Moved Permanently status and append the correct page to the URL. Finally kill the
' script so that processing stops here
If (InStr(Request.ServerVariables("SERVER_NAME"),"www.lewilliamsprinting.com") = 0) then
   Response.Status = "301 Moved Permanently"
   Response.AddHeader "Location", "http://www.lewilliamsprinting.com" _
     + Request.ServerVariables("PATH_INFO")
   Response.End()
End If
%>

Open in new window


Is there something I must do to make the global.asa script take affect? Again, this is my first time using global.asa at all.

Thank you.
0
Comment
Question by:bbdesign
  • 4
5 Comments
 
LVL 26

Expert Comment

by:Dan McFadden
ID: 41889898
Is you site running Classic ASP?  Is Classic ASP enabled in IIS?
 
You could also try HeliconTech ISAPI_Rewrite 3 Lite.   It should work fine in your situation, there is even a configuration example of exactly what you want to do.

Product overview:  https://www.helicontech.com/isapi_rewrite/
Example:  https://www.helicontech.com/isapi_rewrite/doc/examples.htm
--- scroll down to a section labeled "Redirecting non-www version to www"  about half way down.

Dan
0
 

Author Comment

by:bbdesign
ID: 41890060
Classic ASP. Yes, Classic ASP is enabled and running.

I'm aware of Helicon's rewrite software and I have also used IIRF for rewriting before. What I'm specifically wanting to know is if it is possible without any of these other tools.

Thanks.
0
 

Author Comment

by:bbdesign
ID: 41890165
In my example site above:
http://lewilliamsprinting.com/

...the home page is index.html which is not an ASP page/script. Does global.asa not affect non-ASP pages? I was hoping it would be a truly global script that would affect the entire website. But since I haven't worked with global.asa before, I'm not sure.
0
 

Accepted Solution

by:
bbdesign earned 0 total points
ID: 41890177
I may have answered my own question. I don't believe what I am asking is possible with static HTML websites on IIS 6.
0
 

Author Closing Comment

by:bbdesign
ID: 41895655
Researched and found the answer myself.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now