ht访问以保护下载文件夹



我在下载目录的 htaccess 文件中添加了以下行 -

order Deny,Allow
Deny from all

现在我想重写所有网址,

https://example.com/download/myfile.pdf 
to 
https://example.com/get-file.php?directory=download&request=myfile.pdf

以下是我在Web 根目录中的 htaccess 文件-

RewriteEngine On
RewriteBase "/"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L] 
RewriteRule    ^download/([A-Za-z0-9-.]*+)/?$    get-file.php?directory=download&request=$1   [NC,L]
ErrorDocument 404 /invalid-page-name
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP

这行不通。谁能告诉我我哪里犯了错误?非常感谢您的帮助。

请尝试更改

order Deny,Allow
Deny from all

<FilesMatch ".*">
Order Allow,Deny
Deny from All
</FilesMatch>

最新更新