【发布时间】:2016-03-18 02:38:01
【问题描述】:
@Starkeen 在Redirecting the content of a directory, but not the directory itself as well as some of its subdirectories and files 为 Apache 配置解决了这个问题,但我们很快就会迁移到 Nginx。
他非常优雅的 Apache 解决方案:
RedirectMatch ^/category/((?!index|images|menu)[^/]+)/?$ /$1
这里,/category/ 目录中的所有内容——除了/category/index.php、/category/images/ 的内容和/category/menu/ 的内容——都被重定向到根文件夹。
我们尝试了在http://winginx.com/en/htaccess 提供的从 htaccess 到 Nginx 的翻译,
location ~ ^/category/((?!index|images|menu)[^/]+)/?$ {
rewrite ^(.*)$ /$1 redirect;
}
但这没有用。
【问题讨论】: