自从我与.htaccess混淆了一段时间后,我似乎无法完全理解这一点。我有一个网站,例如example.com,我希望example.com/*可以重定向到example.com/collector.html ,除了,我想继续使用子目录example.com/special下的网址。如何使用htaccess重定向除一个子目录以外的所有东西
例如:
- 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
会做的伎俩,但它似乎并没有按照我想要的方式工作。
这可以使所有子目录转到收集器,但不起作用来重定向根目录中的文件,例如, example.com/page.html – 2009-05-29 13:40:16
会发生什么?没有任何重定向,页面是否正确检索? – 2009-05-29 14:04:44
试试这个在同一行:RedirectMatch 302 /\/[^(special\//)|(collector\.html)].*/ /collector.html – 2009-05-29 14:07:31