Forum Moderators: open

Message Too Old, No Replies

.htaccess file type for .asp

         

ldylion214

7:02 am on Nov 16, 2007 (gmt 0)

10+ Year Member



I've been told a .htaccess file won't work on my site because it is .asp. What would be an alternative that would work for me. I have an old javascript code for redirect Would something like this work to redirect my //example.com to //www.example.com?

or Would either of these work?

ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/");
%>

ASP .NET Redirect
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com");
}
</script>

I'm trying to find this on my own. If this should be somewhere else, let me know. I'll post it where it needs to go.

Thanks in advance!
Nicci

[edited by: encyclo at 11:23 am (utc) on Nov. 16, 2007]
[edit reason] switched to example.com [/edit]

mattur

6:30 pm on Nov 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi ldylion214

IIS doesn't use .htaccess, it's an Apache feature.

You can do re-directs using code like your example at the page level. Use a HTTP header checker to confirm it works as expected.

To configure re-directs at the server level on IIS you need access to the IIS MMC or use ISAPI_REWRITE (usually not available on shared hosting).

ldylion214

5:21 am on Nov 20, 2007 (gmt 0)

10+ Year Member



Here is the code that worked:

<%@ Language=VBScript %>
<%
If Request.ServerVariables("SERVER_NAME") <> "www.tribeazure.com" Then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.tribeazure.com/"
End If
%>

One of the guys on another of my forums finally got it for me. Maybe this will be of some help to someone else.

Best, Nicci