< filesmatch>只对一个页只对、LT、filesmatch、GT

由网友(孤影)分享简介:我有一个需要只在首页上有如下Filesmatch在这里.pdf文件要问开放前,但在该网站的其他.pdf文件(没有在主页上)我要自动打开。这是实现这一目标的最佳方式是什么? I have a need to have only the home page have the following Filesmatch wh...

我有一个需要只在首页上有如下Filesmatch在这里.pdf文件要问开放前,但在该网站的其他.pdf文件(没有在主页上)我要自动打开。这是实现这一目标的最佳方式是什么?

I have a need to have only the home page have the following Filesmatch where .pdf files need to ask before opening up, but other .pdf files in the site (not on the home page) I want to open automatically. Is this the best way to accomplish this?

这是一个Word preSS网站,最新版本,主页是一组页面。此外,该网站所有者可以在网站中添加更多的.pdf的链接,所以我不希望她有她每次添加一个文件的时间来处理code到复杂太多。

This is a Wordpress site, latest version, and the home page is a set page. Also, the owner of the site could add more .pdf links within the site so I don't want to complicate it too much where she has to manipulate code every time she adds a file.

下面是目前什么是我的.htaccess文件:

Here is what is currently in my .htaccess file:

# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
ErrorDocument 404 /index.php
ErrorDocument 403 /index.php

#BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.dramanotebook.com/$1 [R,L]


<Files 403.shtml>
order allow,deny
allow from all
</Files>

<FilesMatch ".pdf$">
ForceType applicaton/octet-stream
Header set Content-Disposition attachment
</FilesMatch>

# END WordPress

在此先感谢, 吉姆

Thanks in advance, Jim

推荐答案

我能够通过使用来完成这个&LT;文件&GT;&LT; /文件&GT;

I was able to accomplish this by using <Files></Files>.

例如:

<Files "filenameexample.pdf">
ForceType applicaton/octet-stream
Header set Content-Disposition attachment
</Files>

的技巧是,你需要添加一个&LT;文件&GT;&LT; /文件&GT; 对于要单独控制每个文件。没有选项说所有的PDF此页面上得到保护,但其他网页做别的事情。其实,你could..but你就必须把.htaccess文件每个文件夹中,以恢复回另一种方式的扩展。疯。更快只是做了3个文件,我需要明确。

The trick is you need to add a <files></files> for each file you want to individually control. There are no options to say "all PDF's on this page be protected, but other pages do something else". Actually, you could..but you would have to put an .htaccess file in each folder to "revert" it back to another way for those extensions. Crazy. Faster just to do the 3 files I needed specifically.

我没有发现的网上信息有帮助,也没有任何反应。我只是测试了很多。

I found none of the information online helpful nor any responses. I just tested a lot.

吉姆

阅读全文

相关推荐

最新文章