リダイレクトに関連する問題があります
誰かが使用した場合にリダイレクトを適用したい場合http://mywebsite.com/、URL は にリダイレクトされhttp://www.mywebsite.com/ます。302リダイレクトであることは知っていますが、コーディングに適用する方法がわかりません........リダイレクトを適用するためにどのVBScriptを使用できますか??
私の Web サイトは Classic ASP と VBScript で構築されています。
ありがとう
リダイレクトに関連する問題があります
誰かが使用した場合にリダイレクトを適用したい場合http://mywebsite.com/、URL は にリダイレクトされhttp://www.mywebsite.com/ます。302リダイレクトであることは知っていますが、コーディングに適用する方法がわかりません........リダイレクトを適用するためにどのVBScriptを使用できますか??
私の Web サイトは Classic ASP と VBScript で構築されています。
ありがとう
Request.ServerVariables("HTTP_HOST")ホスト部分を取得して、それがで始まるかどうかを確認するために使用しますwww.。
そうでない場合Response.Redirect()は、302 を実行するため、適切な URL に a を発行するだけです。
例えば
If Left(Request.ServerVariables("HTTP_HOST"), 4) <> "www." Then
Dim newUri
'Build the redirect URI by prepending http://www. to the actual HTTP_HOST
'and adding in the URL (i.e. the page the user requested)
newUri = "http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL")
'If there were any Querystring arguments pass them through as well
If Request.ServerVariables("QUERY_STRING") <> "" Then
newUri = newUri & "?" & Request.ServerVariables("QUERY_STRING")
End If
'Finally make the redirect
Response.Redirect(newUri)
End If
上記は、要求されたページとクエリ文字列が保持されるようにリダイレクトを行います
これを試して:
Response.Status = "302 Moved Temporary"
Response.AddHeader "Location", "http://www.mywebsite.com/"