如何重定向所有请求到一个文件中,除了使用Apache的图像?重定向、图像、文件、Apache

由网友(要一直坚持呀!)分享简介:我有以下内容的.htaccess文件:I have an .htaccess file with the following contents:Options +FollowSymLinks +ExecCGIRewriteEngine OnRewriteRule ^(...

我有以下内容的.htaccess文件:

I have an .htaccess file with the following contents:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(.*)$ entryPoint.php [QSA]
</IfModule>

通过这一点,我想的所有的请求重定向到文件 entryPoint.php ,以便它可以检查它们:

With this, I want all requests to be redirected to the file entryPoint.php so that it can examine them:

如果没有扩展名,是必须是一个模块 如果有一个.PHP,这是一个黑客

如果它是一个巴纽,那么它是一个安全的电话。 If there is no extension, is must be a module If there's a .php, it's a hacking

If it's a .png, then it's a "safe" call.

在图像的情况下,我用的输出头,和的file_get_contents()的内容。我想通了,它比留下的直接的读取。

In case of images, I used to output headers, and file_get_contents() their content. I figured out it's a bit slower than leaving a direct read.

如何prevent此的.htaccess从调用 entryPoint.php 如果对图像的参考?

How to prevent this .htaccess from calling entryPoint.php if there are references for images?

上的code我已经有了额外的反馈是大大AP preciated!

推荐答案

据我了解,你要处理所有非图像丢给你的PHP文件。对吧?

As I understand you want to process all non-images threw your php file. Right?

如果是这样,那么这里就是你所需要的:

If so, then here is what you need:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{REQUEST_URI}  !(.png|.jpg|.gif|.jpeg|.bmp)$
RewriteRule (.*)  entryPoint.php [QSA]

</IfModule>

记住要添加删除任何你想要的图像扩展! 如果我误会了,请告诉我,纠正我的答案!

Remember to add to delete any image extension you want! If I misunderstood,Please tell me to correct my answer!

阅读全文

相关推荐

最新文章