开发者

mod_rewrite catch all .pdf requests

Hi I have a project in which, for a short time, I need to catch all requests to download the pdfs on the site and redirect to single page (which outputs a message explaining why pdf downloads are not available).

I have tried what i thought was the logical rule:

RewriteRule ^\.pdf$ index.php?page=mypdfpage [L]

but without success.

The actual location of all pdfs is /media/pdf/[0-9]/name_of_file.pdf though I believe there should be a rule to catch all .pdfs no matter w开发者_如何学Pythonhat the location.

Any assistance much appreciated.


The rule have to be \.pdf$ the ^ means 'begins with' and . resolve to any character. so you are catching everything which is 4 letters, and last 3 are "pdf" If you need the name of the pdf file the rule will be something like (.*)\.pdf$

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜