301重定向PDF文件

时间:2013-12-13 10:12:33

标签: regex apache .htaccess redirect

我遇到了将单个pdf文件重定向到新位置的麻烦。

RewriteEngine On 
RewriteBase /

#REDIRECT QR CODE LINKS TO A NEW SOURCE
RedirectMatch 301 http://www.sampledomain.eu/assets/fm/download/en-gb/Technical%20documentation/General%20information/Substrates%20table%20Sample.pdf http://www.sampledomain.eu/assets/fm/download/en-gb/Technical%20documentation/Information/01_General%20information/02_Substrates%20table%20Sample.pdf

请注意,网址中有空格

我也尝试了这个没有成功:

#REDIRECT QR CODE LINKS TO A NEW SOURCE
RedirectMatch 301 ^/assets/fm/download/en-gb/Technical%20documentation/General%20information/Substrates%20table%20Sample.pdf$ http://www.sampledomain.eu/assets/fm/download/en-gb/Technical%20documentation/Information/01_General%20information/02_Substrates%20table%20Sample.pdf

我怎样才能让它发挥作用?

1 个答案:

答案 0 :(得分:1)

浏览器/网络服务器将

%20解码为空格字符。

将此规则与正确的正则表达式一起使用:

RedirectMatch 301 "^/assets/fm/download/en-gb/Technical documentation/General information/Substrates table Sample.pdf$" http://www.sampledomain.eu/assets/fm/download/en-gb/Technical%20documentation/Information/01_General%20information/02_Substrates%20table%20Sample.pdf