« Previous Next »

Thread: .htaccess file type for .asp

Last post 07-07-2008 8:11 PM by horjlai. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 11-18-2007, 11:52 PM

    .htaccess file type for .asp

    Hi all,
    I'm new here. 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 //tribeazure.com to //www.tribeazure?

    I've tested more than a few codes on my site. Here are the two my host recommends:

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

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

    Can anyone see anything I may have done wrong? I placed them at the top of the page. I get a 500 Internal Error. Grrr. I have no experience with this so I do need step by step.

    I apologize if this is in the wrong category.  I wasn't sure where to post it. 

    Thanks! Nicci

    Nicci VanCleave
    http://www.tribeazure.com
  • 11-19-2007, 8:11 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 10:27 AM
    • Central NJ
    • Posts 6,078
    • IIS MVPs

    Re: .htaccess file type for .asp

    Are you trying to add all of that at the same time?  The "<script runat" section is for ASP.NET and will not work with classic ASP ...

  • 11-19-2007, 8:25 AM In reply to

    Re: .htaccess file type for .asp

    Easiest would be to use ISAPIRewrite to do this.  Affects all requests that way.  Eeven easier is point your DNS to the same site for both records and it doesn't matter.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 11-19-2007, 9:49 AM In reply to

    Re: .htaccess file type for .asp

    tomkmvp:

    Are you trying to add all of that at the same time?  The "<script runat" section is for ASP.NET and will not work with classic ASP ...

    No, I did try them both but not at the same time.  My host suggests these codes.  The other didn't work either.  However I'm not sure I put it in the correct location on the page.  Also I'm not sure if I customized it exactly right either.

    Best, Nicci

    Nicci VanCleave
    http://www.tribeazure.com
  • 11-19-2007, 9:50 AM In reply to

    Re: .htaccess file type for .asp

    jeff@zina.com:

    Easiest would be to use ISAPIRewrite to do this.  Affects all requests that way.  Eeven easier is point your DNS to the same site for both records and it doesn't matter.

    Jeff

    Jess, Do you mean point my DNS to only //www.tribe?

    Best, Nicci

    Nicci VanCleave
    http://www.tribeazure.com
  • 11-19-2007, 10:39 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 10:27 AM
    • Central NJ
    • Posts 6,078
    • IIS MVPs

    Re: .htaccess file type for .asp

    After thinking about your post again, I wouldn't bother with a redirect and I'm not sure that code would work the way you want it to anyway.  Just make sure both names point to your web server IP address.

  • 11-19-2007, 11:03 PM In reply to

    Re: .htaccess file type for .asp

    Thank you, Tom.  I will do that.

    Also Jeff I see that I wrote Jess.  I'm so sorry about that.  :)

    Best, Nicci

    Nicci VanCleave
    http://www.tribeazure.com
  • 12-13-2007, 12:50 PM In reply to

    Re: .htaccess file type for .asp

    Someone wrote this code for me:


    <%@ Language=VBScript %>
    <%
    CONST CANONICALURL = "www.tribeazure.com"

    If Request.ServerVariables("SERVER_NAME") <> CANONICALURL Then
     Dim HeaderValue
     If  Request.ServerVariables("HTTPS") = "off" Then
      HeaderValue = "http://" & CANONICALURL
     Else
      HeaderValue = "https://" & CANONICALURL
     End If

     If Len(Request.ServerVariables("SCRIPT_NAME")) > 0 Then
      HeaderValue = HeaderValue & Request.ServerVariables("SCRIPT_NAME")
     End If

     If Len(Request.ServerVariables("QUERY_STRING")) > 0 Then
      HeaderValue = HeaderValue & "?" & Request.ServerVariables("QUERY_STRING")
     End If

            Response.Clear
     Response.Status = "301 Moved Permanently"
     Response.AddHeader "Location", HeaderValue
     Response.End
    End If
    %>

    It appears to do the job correctly but someone told me I am playing with fire by adding codes such as this to my site.  I think he was talking about SEO.  Anyway my rankings have dropped drastically.  Could this have something to do with it?  I'm open to hearing anyone's opinion.

    Thanks!  Nicci

    Nicci VanCleave
    http://www.tribeazure.com
  • 07-07-2008, 8:11 PM In reply to

    • horjlai
    • Not Ranked
    • Joined on 07-07-2008, 8:07 PM
    • Posts 1

    Re: .htaccess file type for .asp

    Here is the solution - very simple

    <%
    Dim srv
    srv=Request.ServerVariables("SERVER_NAME")
    if srv="tribeazure.com" then response.redirect "http://www.tribeazure.com"
    %>

     cheers

Page 1 of 1 (9 items)