htaccess mod重写文件先通过php?

发布于 2024-08-29 03:18:22 字数 271 浏览 2 评论 0原文

我有一个充满文件的目录。

最初人们被允许直接链接到这些文件。现在我想首先通过 php 文件运行所有文件。

有人可以帮我解决所需的 .htaccess 吗?用于处理下载的 phpfile 将被称为 download.php,它将有一个名为 $ref 的 get 变量,

所以我需要 noob.com/games.zip 转到 noob.com/download.php?ref=games.zip 但仍然保留 noob.com/games.zip 的 url

谢谢!

I have a directory full of files.

Originally people were allowed to direct link to these files. Now i would like to run all files through a php file first.

Could someone help me with the .htaccess needed to do that? The phpfile used to handle the downloads will be called download.php and it will have a get variable called $ref

So i need noob.com/games.zip to goto noob.com/download.php?ref=games.zip BUT still retaining the url of noob.com/games.zip

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不喜欢何必死缠烂打 2024-09-05 03:18:22

这应该可以为您完成工作:

RewriteEngine On
ReWriteRule ^(((?!download.php).)*)$ /download.php?ref=$1 [L]

...如果您还想保留其他参数...

RewriteEngine On
ReWriteRule ^(((?!download.php).)*)$ /download.php?ref=$1&%{QUERY_STRING} [L]

This should do the job for you:

RewriteEngine On
ReWriteRule ^(((?!download.php).)*)$ /download.php?ref=$1 [L]

...and this is if you want to keep other parameters also...

RewriteEngine On
ReWriteRule ^(((?!download.php).)*)$ /download.php?ref=$1&%{QUERY_STRING} [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文