[英]RedirectMatch and Regex Tomfoolery
我正在尝试将对/ library /的所有请求重定向到外部URL,除非请求.pdf文件。 例如,www.mysite.com / library / section应该重定向到www.externalsite.com,但是www.mysite.com/library/docs/some_pdf.pdf应该提供PDF文件而不进行重定向。 这是我所拥有的:
RedirectMatch permanent /library/!(.*\.pdf) http://www.externalsite.com/
尝试这个:
RedirectMatch permanent /library/(?!.*\.pdf) http://www.externalsite.com/
您可能要匹配整个路径而不是子字符串:
RedirectMatch permanent ^/library/(?!.*\.pdf)$ ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.