SQLite的文件使用的.htaccess preventing直接下载 [英] preventing direct download of SQLite file using .htaccess

查看:170
本文介绍了SQLite的文件使用的.htaccess preventing直接下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道的.htaccess的基础知识,但是爽快地承认,作为一个非专家,当涉及到mod_rewrite的。

I know the basics of .htaccess, but freely admit to being a non-expert when it comes to mod_rewrite.

问题:    我在文档根目录一个SQLite数据库文件(不,我不能移动它离开这里)名为 data.sqlite 。此文件是内部访问由PHP文件,但是,我想通过直接输入网址数据库在浏览器的用户,以防止被'下载'这个文件。

The problem: I have a sqlite db file in the document root (no, I can't move it out of here) called data.sqlite. This file is accessed internally by PHP files, however, I want to protect this file from being 'downloaded' by the user typing the db URL directly into their browser.

我已经使用的.htaccess建立在过去的pretty的网址,并使用mod_rewrite将提供一个很好的解决我的问题想。但是,我重写规则似乎并没有prevent接入后。

I have used .htaccess to create pretty URLs in the past, and thought using mod_rewrite would provide a nice solution to my problem. However, my rewrite rule does not seem to prevent access.

的.htaccess

.htaccess

Options +FollowSymLinks
Options -multiviews

RewriteEngine On
RewriteBase /


RewriteCond %{http_host} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,NC]

##prevent access to any file data.sqlite by redirecing back to index.php
RewriteRule ^data.sqlite$ index.php [L,NC]

##my other rules follow - not shown here

任何想法在那里我与重写脚麻?我敢肯定,这是简单的东西?

Any ideas where I'm going wrong with the rewrite?? I'm sure it is something simple?

编辑:

在理想情况下,我想prevent直接通过URL访问的.sqlite结尾的文件,而不只是data.sqlite

Ideally, I'd like to prevent direct URL access to all files ending in .sqlite, not just data.sqlite

推荐答案

下面是你如何做到这一点,因为我也做到了:

Here's how you do it because I have also done it:

RewriteCond %{HTTP_REFERER} !^http://*.webwarecollection.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://*.webwarecollection.com$      [NC]
RewriteRule .*\.(sqlite)$ - [F,NC]

这篇关于SQLite的文件使用的.htaccess preventing直接下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆