【问题标题】:301 Redirect is not working in ASP301 重定向在 ASP 中不起作用
【发布时间】:2011-10-25 19:05:12
【问题描述】:

我查看了所有的 asp 重定向,它们都说同样的话。我正在尝试将单个 .asp 页面重定向到新的 url。这是我一直看到的代码,并多次尝试将其放在相关页面的开头:

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

它似乎不起作用。它看起来像典型的 .asp 页面,带有 &lt;@ Language=VBScript %&gt; 在顶部后跟 html 代码。还有其他方法可以重定向单个 .asp 页面吗?

【问题讨论】:

    标签: redirect asp-classic


    【解决方案1】:

    我认为括号是这里的麻烦

    <%@Language=VBScript %>
    <%
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://www.new-location.com"
    %>
    

    【讨论】:

    • +1。上面的某个地方似乎有On Error Resume Next。否则,是否会因为括号而发生错误。
    【解决方案2】:

    试试这个...

    <%@ language="VBScript" %>
    <% 
    Response.Status="301 Moved Permanently" 
    Response.AddHeader ( "Location","http://www.new-location.com" ) 
    %> 
    

    【讨论】:

    • 这和问题中的代码有什么区别?
    • 1:
    【解决方案3】:

    我知道我很晚了,但是如果您在重定向之后有 HTML,则需要使用 Response.End():

    <%@ language="VBScript" %>
    <% 
    Response.Status="301 Moved Permanently" 
    Response.AddHeader ( "Location","http://www.new-location.com" ) 
    Response.End()
    %> 
    

    【讨论】:

      猜你喜欢
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多