Solved

Redirect IIS 6 website using global.asa?

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

624 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