RedirectMatch包含不包括的URL?

时间:2015-11-20 12:06:03

标签: apache .htaccess url-redirection mod-alias

我想执行RedirectMatch规则并排除网址:

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

我想要排除这个网址:

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

1 个答案:

答案 0 :(得分:0)

在Root / .htaccess文件中尝试此操作

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

这将重定向

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