我无法弄清楚如何在下载时正确命名其中包含空格的文件名。名字在第一个空格处破裂。例如。文件
how are you.pdf
下载为
how
以下是我的代码。我尝试过很多东西,但迄今为止都没有。
RewriteEngine On
##RewriteBase /
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?consciousnesscoachingacademy.com [NC]
RewriteRule \.(.*)$ - [NC,F,L]
RewriteCond %{QUERY_STRING} ^filename=(.*)$
RewriteRule ^download\.php$ %1
RewriteRule (.*) - [E=file:$1]
Header set Content-type "octet-stream"
Header set Content-disposition "attachment; filename=%{file}e" env=file
答案 0 :(得分:1)
试试这段代码:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?consciousnesscoachingacademy.com [NC]
RewriteRule \.(.*)$ - [NC,F,L]
# file download (attachment)
RewriteCond %{THE_REQUEST} /download\.php\?filename=(.+)\ HTTP/ [NC]
RewriteRule ^download\.php$ %1? [E=file:%1]
Header set "Content-disposition" "attachment; filename=\"%{REDIRECT_file}e\""
Header set "Content-type" "octet-stream"