Skip to content

Instantly share code, notes, and snippets.

@nagasato
Created April 3, 2012 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nagasato/2288987 to your computer and use it in GitHub Desktop.
Save nagasato/2288987 to your computer and use it in GitHub Desktop.
Apache2.2: RedirectMatchで、とあるファイル(やディレクトリ)以外にマッチさせる

例: /foo.html以外へのアクセスは http://www.example.com/ にリダイレクトする。

RedirectMatch "^/((?!foo\.html).*)$" http://www.example.com/

例: サイト閉鎖の際にすべてのページへのアクセスに410を返す。410の応答ページはRedirectMachから除外する。

RedirectMatch gone "^/((?!gone\.txt).*)$"
ErrorDocument 410 /gone.txt

(ドメインとサーバーが生きている間の話)


参考: http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=17238&forum=10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment