2010-07-22 2 views
3

이전 asp 페이지 중 일부를 새 aspx 웹 사이트로 옮겼습니다. (파일 example.asp에 대한) 내가 사용하는 기존의 모든 페이지에서 는 :쿼리 문자열에 매개 변수가있을 때 영구적 인 301 리디렉션 작업을 수행하는 방법은 무엇입니까?

Response.Status = "301 Moved Permanently"; 
Response.AddHeader("Location","http://www.example.com/example.aspx"); 

문제는 페이지가 &이 PARAM2 = 값 2 example.com/example.asp?param=value 때
이 요구된다는 점이다 - 리디렉션이 작동하지 않습니다 ...

누구 ...?

답변

0

쿼리 헤더 매개 변수를 물음표로 구분하여 위치 헤더의 끝에 추가하십시오. 나는 이것이 Request.Url.Query에 있다고 생각한다. 고전적인 ASP 페이지에서 작동합니다

protected void Page_Load(object sender, EventArgs e) 
{ 
    Response.Status = "301 Moved Permanently"; 
    string sQueryString = this.Request.ServerVariables["QUERY_STRING"]; 
    Response.AddHeader("Location", String.Format("http://www.domain.com/example.aspx?{0}", sQueryString)); 
} 
0

당신은 쿼리 문자열을 보장하기 위해 이런 일을 시도 할 수는 걸쳐 실시한다. 기본적으로 smelch가 말한 예입니다.

<%@ Language=VBScript %> 
<% 
Response.Status="301 Moved Permanently" 
Response.AddHeader "Location", "http://www.test.com/default.aspx?" + Request.QueryString 
Response.End 
%> 
관련 문제