mod_rewriteとは Apacheのモジュールのひとつで、アクセスURLを正規表現で書き換えることができます。リダイレクト処理を行うのに便利なモジュールです。 モジュールの解説ドキュメントによれば URLを操作するためのスイス製のアーミーナイフ と例えられるほど、非常に複雑な処理を行えます。 URLからURLへ、同一サーバ内URLだろうが、別サーバURLだろうが問いません。 引数を含む動的URLを通常のHTMLファイルのような静的URLに見せることも可能です。 素晴らしく詳細なマニュアルもありますが、機能が多いだけに情報量が多く読むのも面倒だと思いますので、ここでは、mod_rewriteを使用すると便利な場面を想定して具体的に解説してみたいと思います。 mod_rewriteの基本 ひとまず、mod_rewriteはApacheのモジュールです。インストールされていなければ、サーバ
概要 .htaccessとは、Webサーバの動作をディレクトリ単位で指定・制御できる設定ファイル。最も普及しているWebサーバソフトのApacheで用いられるもので、他にいくつかのWebサーバも対応している。 特定のファイルやディレクトリに対してアクセス元のIPアドレスやドメイン名ごとにアクセスの許可や拒否を設定したり、CGIなどを介したプログラムの実行を許可したり、特定の領域にユーザー認証を設定して特定の閲覧者のみにアクセス許可を限定したり、特定のURLに対してHTTPリダイレクト(自動転送)を設定することができる。指定対象の表現には正規表現を使うこともでき、特定のパターンに当てはまる複数の対象を一括指定できる。 .htaccessをあるディレクトリに置くと、そのディレクトリを頂点とする下層のサブディレクトリやファイル群すべてに対して記述内容が有効となる。サブディレクトリにも別の.hta
.htaccess活用法(6) .htaccess(拡張子がhtaccessということで、ドットが必要です。ファイル名がないので最初戸惑いますが、こういうものだと思ってください。)が利用可能だと、 アクセス制限(Basic認証)が可能。 特定のホスト(IPアドレス。プロバイダ)からのアクセスを制限することが可能 参照元(Referer)によるアクセス制限が可能(画像の直リンク禁止も可能) 特定のユーザーエージェント(ブラウザ・ロボット)からのアクセス制限が可能 ブラウザ経由でのアクセス(http://~)を拒否することも可能(大切なデータファイルを守る) リダイレクトが可能(ページの移転時などに重宝) 404 File Not Foundページのカスタマイズが可能。 拡張子別に文字コードを設定することが可能。(文字化け対策に必須の場合があります。) index.cgiやindex.phpを
現在、WEBサーバのシェアとしてはApacheが過半数を占めています。英国Netcraft社の調査によると2016年4月におけるApacheのシェアは49.15%である(active sitesにおけるシェア。参照:Netcraft: April 2016 Web Server Surveyy)。 2位のnginxを大きく引き離しています。このような世界的に人気の高いApacheをウェブマスターとして使いこなす方法として、このホームページでは.htaccessの利用法について解説します。httpd.confに触ることのできない一般のウェブマスターさんを対象に、「アクセス制限」「カスタムエラーページの設定」「MIMEタイプの設定」など実用度の高い利用法に絞って紹介します。「何をしたいか」のかを中心に、.htaccessの利用法を説明する構成になっています。
リダイレクト Fromにサイトパスを入力、ToにURLを入力 301 Moved Permanently 恒久的に移動 From: To: From: To: From: To: 302 Moved Temporarily 一時的に移動 From: To: From: To: From: To:
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く