4

.htaccess をいじってからしばらく経ちましたが、これを正しく理解できないようです。example.com などのサイトがあり、example.com/* を example.com/collector.html にリダイレクトする必要があります。ただし、サブディレクトリ example.com/special の下の URLを除き、引き続き作業を行いたいと考えています。

例えば:

  • example.com/page.html は example.com/collector.html にリダイレクトする必要があります
  • example.com/foo/bar は example.com/collector.html にリダイレクトする必要があります
  • example.com/special/page.html はリダイレクトしないでください

私は次のようなことを考えていたでしょう

RedirectMatch 302 ^/[^(special)]/.* /collector.html
RedirectMatch 302 ^/[^(collector.html)/]* /collector.html

トリックを行うでしょうが、私が望むようには機能しないようです。

4

4 に答える 4

4

もしかしてこれ?(mod_rewrite が必要)

RewriteEngine On
RewriteRule !^(special(/.*)?|collector\.html)$ collector.html [R,L]
于 2009-05-29T13:57:32.063 に答える
0

これを試して:

RedirectMatch 302 /\/[^(special)]\/.+/ /collector.html 
RedirectMatch 302 /\/[^(collector\.html)]/ /collector.html
于 2009-05-29T13:29:30.810 に答える
0

多分...?

RewriteEngine on
RewriteRule ^(?!special) collector.html [R,NC]
于 2009-05-29T17:56:29.147 に答える