自从我弄乱 .htaccess 已经有一段时间了,我似乎无法完全正确地做到这一点。我有一个站点,例如 example.com,我希望 example.com/* 重定向到 example.com/collector.html,但我想继续工作的子目录 example.com/special 下的 URL 除外。
例如:
我会认为像
RedirectMatch 302 ^/[^(special)]/.* /collector.html
RedirectMatch 302 ^/[^(collector.html)/]* /collector.html
会做的伎俩,但它似乎并没有像我想要的那样工作。
最佳答案
也许这个? (需要 mod_rewrite)
RewriteEngine On
RewriteRule !^(special(/.*)?|collector\.html)$ collector.html [R,L]
关于.htaccess - 如何使用 htaccess 重定向除一个子目录之外的所有子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/925913/