Solved

Redirect IIS 6 website using global.asa?

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

Logparser is the smartest tool I have ever used in parsing IIS log files and there are many interesting things I wanted to share with everyone one of the  real-world  scenario from my current project. Let's get started with  scenario - How do w…
First of all, clustering IIS is something you should rarely consider doing. In almost all cases, Microsoft Network Load Balancing (NLB) (http://technet.microsoft.com/en-us/library/cc758834(WS.10).aspx) is a much better solution when you need to p…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

815 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

11 Experts available now in Live!

Get 1:1 Help Now