Apache的重写:简单的异常不工作的图像类型 [英] Apache Rewrite: Simple exception not working for image types

查看:103
本文介绍了Apache的重写:简单的异常不工作的图像类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题看起来很简单但对我来说我似乎无法得到它的工作。

This question seems simple to me though I can't seem to get it to work.

我试图做一个简单的重写,除了定义图像类型的所有请求。

I'm trying to do a simple rewrite for all requests except defined image types.

三个非常重要的澄清......

Three VERY important clarifications...

1)。这是正在做的图像目录中的.htaccess文件,从浏览器访问位于 example.com/images / 这样.htaccess文件位于的public_html /图片/的.htaccess的本地的。

1.) This is being done with the .htaccess file in the image directory that accessed from a browser is located at example.com/images/ so the .htaccess file is located at public_html/images/.htaccess locally.

2。)这种解决方案需要与我从其他人收到真棒帮助的工作,在这个问题很好地发挥...

2.) This solution needs to play nicely with the work I received awesome help from other people at this question...

<一个href="http://stackoverflow.com/questions/9151876/apache-rewrite-image-directory-based-on-http-host/9154059">Apache重写:基于HTTP主机图像目录

3)我使用的是共享主机,VPS没有的或专用的,所以我的访问是有限的。我知道这不会是复杂的任何方式。

3.) I'm using shared hosting, not VPS or dedicated so my access is limited; I know this isn't going to be complicated any way.

我已经试过以下(连同它的修改)都没有成功...

I've tried the following (along with modifications of it) without success...

的public_html /图像/的.htaccess

RewriteEngine on
RewriteRule !\.(gif|jpg|png)$ index.php?q=$1 [L]

我会很乐意作出澄清,以及两个了票,并接受一个工作的答案。我想我可能只是简单的东西在这里...

I'll be happy to make clarifications as well as both up-vote and accept a working answer. I think I'm probably just missing something simple here...

推荐答案

我presume你想重定向一切的index.php 当请求图片文件夹不是一个请求到图像文件中。

I presume you are trying redirect everything to index.php when the request to images folder is not a request to an image file.

试试这个:

RewriteEngine on
RewriteCond %{REQUEST_URI} !\.(gif|jpg|png)$ [NC]
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

这篇关于Apache的重写:简单的异常不工作的图像类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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