Solved

Redirect IIS 6 website using global.asa?

Posted on 2016-11-16
5
47 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 28

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filktering Alphabetically 8 46
ASP AND XML 3 42
Update the value of table B with value of table A tables inner join 6 101
Customising IE behaviour on certain pages 2 100
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…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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