0

我有一堆 PDFS 在:/uploads/dashboard/

我想做的是,如果从此目录请求 PDF,则重定向到一个脚本,该脚本检查用户的当前会话是否允许他们访问 PDF。如果用户被允许,脚本将提供 PDF。

这就是我所在的位置:

RewriteCond %{REQUEST_URI}/dashboard \.(pdf)$ [NC]   # If filename ends with .pdf and is in the 'dashboard' directory
RewriteRule ^(.*)$ dl/$1 [L,R]              # Redirect the user to the auth script

但是,我不断收到当前代码的 404 错误。

这是一个带有 PHP 5.3 的 Zend Framework 应用程序 下面是我的 .htaccess 的全部内容:

php_flag magic_quotes_gpc Off

SetEnv APPLICATION_ENV development

RewriteEngine On

# Force trailing slash
RewriteCond %{REQUEST_URI}/dashboard \.(pdf)$ [NC]    # If filename ends with .pdf or .cdr
RewriteRule ^(.*)$ dl/$1 [L,R]              # Redirect the user to the other site

RewriteCond %{REQUEST_URI} !.(jpe?g|gif|png|js|css|swf|flv)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ %{REQUEST_URI}/ [L,R=301]

RewriteCond %{REQUEST_URI} .(jpe?g|gif|png|js|css|swf|flv)$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我怎样才能做到这一点?

非常感谢

4

1 回答 1

2

你只需要这样的东西..

RewriteRule ^path/to/pdfs/(.*).pdf       dl/$1.pdf [NC, L]
于 2012-09-19T10:28:50.120 回答