• ベストアンサー
※ ChatGPTを利用し、要約された質問です(原文:httpリダイレクトについて)

HTTPリダイレクトを使用してWeb.configに記述を追加する方法

このQ&Aのポイント
  • Web.configファイルを使用してHTTPリダイレクトを実装するための手順を説明します。
  • 既存のsystem.webServerセクションに新しいsystem.webServerセクションを追加し、httpRedirect要素を使用してリダイレクト先を指定します。
  • Web.configファイルを編集する際は、正しい構文と要件に従うことが重要です。

質問者が選んだベストアンサー

  • ベストアンサー
回答No.1

IISは7.0か7.5の環境だと想定しますが、以下の様にWeb.configを構成すると動作すると思います。 HTTPリダイレクトの各属性についてや、挙動の制御についてはTechNetなどのドキュメントを参照して下さい。 下記の例では、クライアントでWebサイトに「.asp」の拡張子を付けてアクセスした時、302のStatus Codeを返してOKWaveのトップページにリダイレクトします。 なお、既定のドキュメントやHTTPリダイレクトの機能を使用する場合、それぞれのIISのコンポーネントをインストールしておく必要があります。 [Web.config構成例] -------------------------------------- <configuration> <system.webServer> <defaultDocument> <files> <clear /> <add value="index.aspx" /> <add value="index.html" /> <add value="index.htm" /> </files> </defaultDocument> <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found"> <add wildcard="*.asp" destination="http://okwave.jp/" /> </httpRedirect> </system.webServer> </configuration> -------------------------------------- [参考資料] ◆HTTP リダイレクト http://technet.microsoft.com/ja-jp/library/ee431604.aspx ◆既定のドキュメント http://technet.microsoft.com/ja-jp/library/ee431582.aspx

alaninoue
質問者

お礼

ありがとうございました。

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • 動的URLから静的URLへの301リダイレクト

    下記のように動的URLを静的なURLに置き換えています。 http://www.sample.com/dir/aaa/index.php?content_id=1 ↓ http://www.sample.com/aaa_index.content_id_1.htm この動的URLを、置き換えた静的URLへ301リダイレクトさせたいのですが、うまくいきません。 htaccessの記述を下記のようにしましたが、多分、動的URLの「?」があるためうまくいかないようです。 RewriteEngine on RewriteBase / RewriteRule ^dir/aaa/index\.php?content_id=(.*)$ /aaa_index.content_id_$1.htm [R=301,L] 「?」が含まれる動的URLから静的URLに301リダイレクトさせたい場合、どのように記述すれば良いでしょうか?

  • 301リダイレクトはしばらく経つと移動しなくなる?

    301リダイレクトを設定した時、しばらく経つ(数時間)と移動しなくなったのですが、こんなことってあるのでしょうか? 単なる記述間違いでしょうか???でも設置当初はちゃんと動作していたので、記述間違いではないと思うのです。 <Files ~ \"^.(htaccess|htpasswd)$\"> deny from all </Files> Redirect permanent /bbb/test.html http://www.aaa.com/bbb/test.html Redirect permanent /bbb/ http://www.aaa.com order deny,allow ディレクトリbbbにアクセスしたら別ドメインのindexに移動するように設定し、bbbの特定のhtmlのみ同じく特定のURLに移動するように設定してます。 記述している優先順位の内容も考えて記述に特に間違いは無いと思うのですが・・・数時間経つと一番上に記述している命令文が効かなくなるのです。 「ページが見つかりません」とか「表示できません(404エラーと思われる)」とか表示するのです。 数時間経過後、というのが気になります。 Web判定で拒否されるのでしょうか?そんなことってあるのでしょうか? ちょっと初めてのケースなので質問してみました。 もう一度htaccess作り直して設置しました。 現在はちゃんと移動してくれますが・・・数時間後また効かなくなるかもしれないと思うとものすごく困ります。 何かご存知な方がいればご教授お願いします。

  • エクセル VBA チェックボックスについて

    よろしくお願い致します。 OS:XP エクセル2003 VBAのことは、まったくの初心者です。 質問なのですが、下記のようなチェックボックス7にチェックが入れば、チェックボックス8~11に自由にチェックが入れれるようになり、逆にチャックボックス7にチェックが入ってない場合は、チェックボックス8~11のチェックはクリアされ、チェックできないものを作りました。 ここから、チェックボックス7にチェック入れたあとは、必ずチェックボックス9~11のどれかにチェックが入っている状態(ラジオボタンのような)で、チェックボックス7にチェックが入ってなかったら、8~11のチェックがクリアで尚且つ、チェックができなくなるようにするにはどうすればよいでしょうか? よろしくお願い致します。 Private Sub CheckBox7_Click() If CheckBox7.Value = True Then CheckBox8.Enabled = True CheckBox9.Enabled = True CheckBox10.Enabled = True CheckBox11.Enabled = True Else CheckBox8.Value = False CheckBox9.Value = False CheckBox10.Value = False CheckBox11.Value = False CheckBox8.Enabled = False CheckBox9.Enabled = False CheckBox10.Enabled = False CheckBox11.Enabled = False End If End Sub

  • c# 他プロセス起動 リダイレクト(入力) バイナリファイルの場合

    現在、c#で他プロセスを起動させるプログラムを組んでいるのですが、リダイレクトでつまづいています。 (コンパイルが出来ない->どう記述すれば良いのか分からない。) ファイルストリームのReadはデータをByteの配列に格納しますが、リダイレクト入力のwriteはcharの配列を引数としているみたいで、どう記述すれば良いのか分かりません。 記述方法または参考URLを教えていただけないでしょうか? --source--  System.IO.Stream retstream = new FileStream(wkPath, FileMode.Open, FileAccess.Read, FileShare.Read);  System.Diagnostics.Process myProcess = new System.Diagnostics.Process();  myProcess.StartInfo.FileName = "C:\\Program Files\\proc\\process.exe";  myProcess.StartInfo.UseShellExecute = false;  myProcess.StartInfo.RedirectStandardInput = true;  myProcess.StartInfo.RedirectStandardOutput = true;  if (strmInput.Length > 0) {   int num = 0;   byte[] bufWk = new byte[65536];   while (true) {    num = strmInput.Read(bufWk, 0, bufWk.Length);    if (num == 0) {     break;    }    myProcess.StandardInput.Write(bufWk, 0, num); //←コンパイルエラー   }  } --エラー内容-- System.IO.TextWriter.Write(char[], int, int)' に最も適しているオーバーロード メソッドには無効な引数がいくつか含まれています。 引数 '1': 'byte[]' から 'char[]' に変換できません。

  • フォーム認証について

    ASP.NETにてフォーム認証を行おうとしています。 資料を参考にサンプルを実行しようとしているのですが、さわりの段階で早くも行き詰りました。 web.configに <authentication mode="Forms"> <forms name="formauthsample" loginUrl="Login.aspx" protection="All" timeout="30" path="/"> </forms> </authentication> と記述し、Login.aspx以外にもページを用意して、それらのページにダイレクトにアクセスした際にLogin.aspxにリダイレクトされるというのをテストしたかったんですが、リダイレクトされずにページが表示されてしまうのです。 web.configは上記設定だけでは足りないのでしょうか? または、根本的に勘違いをしていますでしょうか? アドバイスを宜しくお願いします。

  • asp.NET初心者です。「 ’Context’は’○○○’のメンバで

    asp.NET初心者です。「 ’Context’は’○○○’のメンバではありません。」というエラーが出て困っています。 「Inherits」が原因のようなのですが、役割がいまいち分かりません。 ご教授よろしくお願いします。 【あ.aspx】 1行目:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="answer.aspx.vb" Inherits="○○○" %> ・・・中略・・・ <!-- ヘッダー --> <div id="header"> <h1><%=SiteMap.CurrentNode.Title%>!</h1>  ←sitemapで指定したタイトルをヘッダに表示。 </div> ============================================================= 【Web.siteMap】 <?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="def.aspx" title="Welcome" description="homepage"> <siteMapNode url="あ.aspx" title="ようこそ" description="あいう" /> ←何をいれてよいのでしょうか? </siteMapNode> </siteMap> ============================================================= 【Web.config】 <siteMap enabled="true"> <providers> <add name="JaSiteMapProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" /> </providers> </siteMap> ============================================================= よろしくお願いします。

  • マクロでセル内の改行を削除する方法

    システムから抽出したCSVファイルをExcelで読み込むと同時に不要な列を削除します。 その際、セル内の改行が邪魔で行がずれてしまいます。 すでに記述したコードを生かしながら、セル内の改行を削除する方法はありますでしょうか? 以下がコードです Private Sub CommandButton1_Click() '//Sheet7のセルをクリア Sheets("Sheet7").Cells.Clear '// Sheet7のA1にissue_export.csvを読み込み With Sheets("Sheet7").QueryTables.Add(Connection:="TEXT;C:\*****.csv", Destination:=Sheets("sheet7").Range("A1")) Dim R As Range For Each R In Sheets("Sheet7").Range("A1") R.Value = Trim(Replace(R.Value, vbCr, "")) R.Value = Trim(Replace(R.Value, vbLf, "")) Next R .Name = "test" .FieldNames = True .RowNumbers = False .Refresh BackgroundQuery:=False .RefreshPeriod = 0 .RefreshOnFileOpen = False .PreserveFormatting = True .AdjustColumnWidth = True .FillAdjacentFormulas = False .RefreshStyle = xlInsertEntireRows .SavePassword = False .SaveData = True .TextFilePromptOnRefresh = False .TextFileParseType = xlDelimited .TextFileStartRow = 1 .TextFilePlatform = 65001 .TextFilePlatform = xlWindows .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = False .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = True .TextFileSpaceDelimiter = False .TextFileTrailingMinusNumbers = False .TextFileColumnDataTypes = Array(9, 9, 9, 9, 2, 9, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 2, 2, 2, 9, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9) .Refresh .Parent.Names(.Name).Delete .Delete End With End Sub

  • .htaccessの記述方法(このファイルを隠す。エラーページ)

    .htaccessファイルで下記のようなことをする記述方法を教えて下さい。 (1)指定ページが見つからない、削除されてしまったっ場合。 参考:http://allabout.co.jp/internet/hpcreate/closeup/CU20031019A/index2.htm ErrorDocument 404 /notfound.html (2).htaccess自体を隠す。 参考:http://htaccess.pasoa.com/itself.htm <Files ~ "^\.ht"> deny from all </Files> ファイルに <Files ~ "^\.ht"> deny from all </Files> ErrorDocument 404 /notfound.html 記述したのですが、エラーが出ました。 また、設置は、.htaccess・notfound.htmlをアスキーモードで、index.htmlと同じ位置にアップロードし、属性を606する。

    • ベストアンサー
    • HTML
  • [ASP.NET] Web.configからの値取得

    ASP.NET(VBを利用)についてお尋ねいたします。 小さなプロジェクトを新規に作成し、 「web.config」の中で <configuration> <appSettings> <add key="connStr" value="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=XX;Initial Catalog=Northwind;Data Source=RED;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=RED;Use Encryption for Data=False;Tag with column collation when possible=False" /> </appSettings> <system.web> (以下略) と記載。 **.aspx.vbのほうでここで記載したkeyの値を取得し、**.aspxのラベルに出力したいと思ったのですが どうしたらいいでしょうか? 「**.aspx.vb」 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim aa As New AppSettingsReader Dim str As String = "connStr" Dim st As System.Type st = aa.GetType()     'Label1.Text = aa.GetValue(str, st)     ??    End Sub また、このkeyを同一ソリューションの中の複数プロジェクトで利用したいときは、うえのような記述(web.config)でよいでしょうか? このkeyにDBサーバーへの接続文字列を記載して同一ソリューションの各プロジェクトで利用したいと思っているのですがうまくいかず困っています。 アドバイスまたは小さなサンプルでもよいので教えていただけませんか? お願いいたします。

  • データのある所まで指定したい

    下記のようにB3からB80までマクロ実行できる様に設定しておきます。 例えばB38までしかデータがない場合、B39でデバッグになってしまいます。 データの入っている所まで実行できるようにお願い致します。 e = 70 ***************************************************** Dim y3 As String y3 = Range("B3").Value Dim cp3 As String cp3 = Range("P3").Value With ActiveSheet.QueryTables.Add(Connection:= _ "URL;" & y3, Destination:=Range("E" & e + 1)) .Name = "000" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingNone .WebTables = "" & cp3 .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With e = Range("E65536").End(xlUp).Row ******************************************************      ・      ・      ・ ****************************************************** Dim y80 As String y80 = Range("B80").Value Dim cp80 As String cp80 = Range("P80").Value With ActiveSheet.QueryTables.Add(Connection:= _ "URL;" & y80, Destination:=Range("E" & e + 1)) .Name = "000" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingNone .WebTables = "" & cp80 .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With e = Range("E65536").End(xlUp).Row ********************************************************