LoginSignup
2
0

More than 5 years have passed since last update.

mod_rewrite での shebang(#!) URL対応

Posted at

やりたいこと

  • /foo/bar#!test1 ⇒ /foo/bar#!test2 のようなリダイレクトをしたい

shebang(#!) ってなに?

hash(#)、bang(!)でshebang(シバン)というもの。
 hash = フラグメント、Ajax対応
 bang = googlebotでのクロール対応
という感じですかね。

mod_rewrite設定

shebang 以下は # でフラグメントとなるため、 apache の REQUEST_URI 変数には /foo/bar しか入ってこない。shebang での条件判定は実現不可なようす・・・

RewriteRule ^/foo/bar#!test1$ /foo/bar#!test2 [R]  # shebangでの条件判定はできない
RewriteRule ^/foo/bar$ /foo/bar#!test2 [R,NE]      # NEでエスケープさせないようにして転送は可能
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0