我在下载目录的htaccess文件中添加了以下几行-
order Deny,Allow
Deny from all
现在我要重写所有的URL,
https://example.com/download/myfile.pdf
to
https://example.com/get-file.php?directory=download&request=myfile.pdf
以下是我在网络根目录中的 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
这不起作用。请谁能告诉我我在哪里犯错?非常感谢您的帮助。
答案 0 :(得分:0)
请尝试更改
order Deny,Allow
Deny from all
到
<FilesMatch ".*">
Order Allow,Deny
Deny from All
</FilesMatch>