0

Any http request (e.g. to pdf) should be redirected to validate.php so if you call an URL (e.g. http:...../whatever/whatever/1.pdf), htaccess should execute validate.php instead.

I went through many examples on web and stackoveflow, no luck yet. Since most work fine for many people, I guess there must be something wrong with my server.

How can I solve this issue?

Thanks

Note: htaccess and validate.php files are stored in the root.

And many more.

4

5 回答 5

1

将此代码放入您的DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteRule \.pdf$ /validate.php [L,NC]
于 2013-11-14T16:20:22.123 回答
1

问题是您将 Apache.htaccess重定向和授权与您想要的应用程序级别的行为混为一谈。至少这是我在这里假设的,因为您希望每个对 a 的请求都通过在访问之前.pdf调用的脚本。validate.php.pdf

当我说你在混淆时,强制验证的逻辑应该在你的validate.php或你的 PHP 应用程序的更大框架中。然后,该脚本应验证用户(在设置 cookie 或会话变量或您可能拥有的任何验证方案之后.pdf)下载文件。

这就是说,这不是一个简单的问题来回答你描述的方式。

于 2013-11-14T16:22:52.843 回答
1

将此添加到您的 .htaccess 文件中,在 < IfModule mod_rewrite.c > 部分中

RewriteEngine On
RewriteRule ^ validate.php [L]
于 2013-11-14T16:21:57.937 回答
0

就这样:

# Turn On RewriteEngine
RewriteEngine On
# Set RewriteBase 
RewriteBase /
# Redirect any http request to validate.php
RewriteRule . /validate.php [NC,L]
于 2013-11-14T16:20:32.753 回答
-1
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ validate.php [L]

那这个呢?

于 2013-11-14T16:37:08.577 回答