RedirectMatch 与排除网址?

RedirectMatch with excluding URLs?

我想执行 RedirectMatch 规则并排除 url:

RedirectMatch 301 /citycards/citycards-locations/muenchen/((?!trachtenvogl).*) city-news.info/citycards/citycards-locations/muenchen

我想排除这个 url:

http://www.city-news.info/citycards/citycards-locations/munchen/citycards-trachtenvogl-reichenbachstr-47-munchen 来自redirectMatch 你能看出错误吗?我怎样才能排除第二个 url?我希望有人能帮助我

在你的 Root/.htaccess 文件中试试这个

RedirectMatch ^/((?!citycards/citycards-locations/munchen/citycards-trachtenvogl-reichenbachstr-47-munchen).+)$ http://city-news.info/citycards/citycards-locations/muenchen/

这将重定向

http://city-news.info/foo/bar

http://city-news.info/citycards/citycards-locations/muenchen/foo/bar

这不会重定向:

http://city-news.info/citycards/citycards-locations/munchen/citycards-trachtenvogl-reichenbachstr-47-munchen