View Full Version : .htaccess file type for .asp
ldylion214
11-15-2007, 10:09 PM
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?
ldylion214
11-16-2007, 01:32 AM
Would either of these work?
ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.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.new-url.com");
}
</script>
I'm trying to find this on my own. I think I'll post this is the database section.
incrediblehelp
11-16-2007, 04:39 PM
Nicci have you tested either of them on your website? I think that would be the best way to find out :).
Here is more 301 redirection help (http://www.jaankanellis.com/301-redirection-help/)
ldylion214
11-16-2007, 11:49 PM
Hey I recognize that green face! :) Yes I will test them out as you suggested. I guess the worse can happen is I have to take the code out.
Thanks for the help and the link!
Best, Nicci
PS. Question. Where on the page does this code go?
ldylion214
11-17-2007, 08:29 PM
Nicci have you tested either of them on your website? I think that would be the best way to find out :).
Here is more 301 redirection help (http://www.jaankanellis.com/301-redirection-help/)
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.
Thanks! Nicci
incrediblehelp
11-19-2007, 02:00 PM
Have you asked your host for support on this issue?
ldylion214
11-19-2007, 07:50 PM
Have you asked your host for support on this issue?
Yes, they only said do a 301 Header Redirect. The above code is what I found listed on their site. From what I'm reading an IISrewrite keeps coming up. I'm in over my head with this stuff.
incrediblehelp
11-19-2007, 09:40 PM
Nicci I dont see the redirect code anywhere on the home page.
ldylion214
11-19-2007, 10:05 PM
Nicci I dont see the redirect code anywhere on the home page.
I took if off because it was causing the 500 error. Dubbya suggested I contact the host and tell them to configure under IIS where both URLs resolve to the same domain. I sent them a message. I should hear back within 24 hours.
Do you see what I may have done wrong in the code?
Thanks!
Best, Nicci
sunpost
11-19-2007, 11:16 PM
Do you see what I may have done wrong in the code?
it looks like you are in a loop that redirects regardless of the domain name. you might want to try something like the script below:
<%@ 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
%>
it should skip the redirect if the SERVER_NAME is Native American Jewelry - American Indian Jewelry (http://www.tribeazure.com)
ldylion214
11-19-2007, 11:22 PM
it looks like you are in a loop that redirects regardless of the domain name. you might want to try something like the script below:
<%@ 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
%>
it should skip the redirect if the SERVER_NAME is Native American Jewelry - American Indian Jewelry (http://www.tribeazure.com)
That didn't work either. I'm not sure what the Server name is. I'll need to check with my host I suppose. This is just making me crazy. lol.
Thanks! Best, Nicci
sunpost
11-19-2007, 11:40 PM
you are right that would not work. A syntax error in the Response.AddHeader line. the one below should work:
<%@ 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
%>
ldylion214
11-20-2007, 12:07 AM
you are right that would not work. A syntax error in the Response.AddHeader line. the one below should work:
<%@ 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
%>
You are a genius!!! Thank you so much. It has no apparent errors to me. I'm going to run thru it but it loads and redirects.
I appreciate that so much.
Best, Nicci
sunpost
11-20-2007, 12:15 AM
Just keep in mind that script only works for the home page. if you put it on the inner pages it will just redirect to the home page. it also does not account for HTTPS if that is required.
ldylion214
11-20-2007, 12:26 AM
Just keep in mind that script only works for the home page. if you put it on the inner pages it will just redirect to the home page. it also does not account for HTTPS if that is required.
I only put it on the home page but since you mentioned it could it be tweaked to work with any other page if I ever needed to di that? Also Im not sure what you mean about the HTTPS. When I type in //http://tribeazure.com it goes to //www.tribe automatically.
Webnauts
11-20-2007, 12:51 AM
Nicci if you are doing all this stuff on your living site you are going into big trouble.
To be honest I see you are playing pretty well with fire.
The HTTPs issue which someone mentioned above is your next big issue.
Good luck.
sunpost
11-20-2007, 01:01 AM
This script should rebuild the url and the querystring too.
<%@ 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
%>
ldylion214
11-20-2007, 01:07 AM
Nicci if you are doing all this stuff on your living site you are going into big trouble.
To be honest I see you are playing pretty well with fire.
The HTTPs issue which someone mentioned above is your next big issue.
Good luck.
John,
Yes as a matter of fact I did but for now I've taken the code off. I'm keeping the code sunpost made for me until I find out more about what I am to do.
Sunpost,
Thank you very much for helping me. I guess my next big step is the HTTPS. If nothing else I am learning all kinds of things I never even knew existed with websites. WOW!
Best to you both, Nicci
ldylion214
11-20-2007, 01:11 AM
This script should rebuild the url and the querystring too.
<%@ 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
%>
Hi Sunpost,
does this code address the issue you mentioned and John also mentioned? The HTTPs?
Best, Nicci
sunpost
11-20-2007, 02:07 AM
Yes. But it does introduce a potential issue with the default page(index.asp). It will redirect Native American Jewelry - American Indian Jewelry (http://tribeazure.com) to Native American Jewelry - American Indian Jewelry (http://www.tribeazure.com/index.asp).
You will need to decide which way you want to handle the default pages. If your goal is to optimize, I see a few conflicts on your inner pages with the link to the home page...
The home page uses http://www.tribeazure .com/index.asp for the Home link and the Native American Jewelry Home link uses http://www.tribeazure .com/
The contact us page uses http://tribeazure .com/ for the Home link and the link on the picture. The Native American Jewelry Home link uses http://www.tribeazure .com/
ldylion214
11-20-2007, 02:33 AM
Yes. But it does introduce a potential issue with the default page(index.asp). It will redirect Native American Jewelry - American Indian Jewelry (http://tribeazure.com) to Native American Jewelry - American Indian Jewelry (http://www.tribeazure.com/index.asp).
You will need to decide which way you want to handle the default pages. If your goal is to optimize, I see a few conflicts on your inner pages with the link to the home page...
The home page uses http://www.tribeazure .com/index.asp for the Home link and the Native American Jewelry Home link uses http://www.tribeazure .com/
The contact us page uses http://tribeazure .com/ for the Home link and the link on the picture. The Native American Jewelry Home link uses http://www.tribeazure .com/
I can go and change them to all point to //www.tribe without the index.asp if that would be best. I realize I have a lot of inconsistencies. I am trying to learn all this stuff. I really appreciate all you are doing to help me.
Best, Nicci
ldylion214
11-29-2007, 04:44 PM
This script should rebuild the url and the querystring too.
<%@ 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
%>
Thanks Sunpost! This seems to be error-free. I would appreciate anyone running thru the site to check for any errors I may have missed.
ldylion214
11-29-2007, 05:10 PM
The only thing I can find is it may be loading slower. Anyone else find that?
ldylion214
12-01-2007, 11:41 PM
I'm talking to myself here but here goes again. lol.
I notice I have more pages in the supplemental index on Google. Could it be due to this new code?