Skip to content

Instantly share code, notes, and snippets.

@sukeharu
Last active July 13, 2016 16:49
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 sukeharu/f6ac95f850ff80169559a28110f6be9f to your computer and use it in GitHub Desktop.
Save sukeharu/f6ac95f850ff80169559a28110f6be9f to your computer and use it in GitHub Desktop.
Apache 2.x で、特定のディレクトリを除きリダイレクトする方法。

Apache 2.x で、特定のディレクトリを除いてリダイレクト

サイトのすべてのファイルを http://www.example.com にリダイレクトする。ただし、dir1ディレクトリ以下は除外する(リダイレクトしない)。

RedirectMatch 301 "^/((?!dir1).*)$" http://www.example.com/

除外するディレクトリが複数ある場合、たとえばdir1だけでなくdir2以下も除外するときはこうする。

RedirectMatch 301 "^/((?!(dir1|dir2)).*)$" http://www.example.com/

参考にしたページ:https://gist.github.com/nagasato/2288987

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