Solved

Redirect IIS 6 website using global.asa?

Posted on 2016-11-16
5
39 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 27

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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