Apache Rewrite:简单异常不适用于图像类型
这个问题对我来说似乎很简单,但我似乎无法让它发挥作用。
我正在尝试对除定义的图像类型之外的所有请求进行简单的重写。
三个非常重要的说明:
这是通过从浏览器访问的图像目录中的 .htaccess 文件来完成的,该文件位于 example.com/images/,因此 .htaccess 文件位于public_html/images/.htaccess 本地。
这个解决方案需要与我从其他人那里收到的关于这个问题的出色帮助很好地配合:Apache Rewrite:基于 HTTP 主机的图像目录
我使用的是共享主机,而不是 VPS 或专用主机,因此我的访问受到限制;我知道这不会很复杂。
我已经尝试了以下操作(及其修改)但没有成功:
public_html/images/.htaccess
RewriteEngine on
RewriteRule !\.(gif|jpg|png)$ index.php?q=$1 [L]
我想我可能只是在这里错过了一些简单的东西。
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:
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.
This solution needs to play nicely with the awesome help I received from other people at this question: Apache Rewrite: image directory based on HTTP host
I'm using shared hosting, not VPS or dedicated so my access is limited; I know this isn't going to be complicated anyway.
I've tried the following (along with modifications of it) without success:
public_html/images/.htaccess
RewriteEngine on
RewriteRule !\.(gif|jpg|png)$ index.php?q=$1 [L]
I think I'm probably just missing something simple here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当对
images
文件夹的请求不是对图像文件的请求时,我假设您正在尝试将所有内容重定向到index.php
。试试这个:
I presume you are trying redirect everything to
index.php
when the request toimages
folder is not a request to an image file.Try this: