无法根据 mod_aliased 目录中存在文件进行 mod_rewrite 吗?
我正在尝试在我的 .htaccess 文件中执行类似以下操作:
Alias /assets /location/of/files
RewriteCond %{REQUEST_URI} ^/assets/[0-9]+.jpg$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /build_thumbnail.cfm?path=%{REQUEST_URI} [QSA,L]
因此理论上它非常简单:
- 从以 /assets/ 开头的 url 请求图像
- apache 检查文件是否存在
- 如果找到,则提供该文件
- 如果没有,则运行脚本。
这在其他地方工作正常,但这是我第一次尝试在作为别名包含的目录上使用它。据我了解,Mod Rewrite 在 Mod Alias 之前运行,这肯定会导致它不起作用(事实上,我的 Alias 行位于 apache conf 中,而其余行位于 .htaccess 中)。
有没有办法让 Mod Rewrite 确认别名目录?
是否可以将 Alias 行更改为 Rewrite 行?
I'm trying to do something like the following in my .htaccess file:
Alias /assets /location/of/files
RewriteCond %{REQUEST_URI} ^/assets/[0-9]+.jpg$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /build_thumbnail.cfm?path=%{REQUEST_URI} [QSA,L]
So in theory it's quite straightforward:
- an image is requested from a url starting with /assets/
- apache checks for the existence of the file
- if found, the file is served
- if not, a script is run instead
This is working fine in other places but this is the first time I've tried to use it on a directory included as an Alias. As I understand it Mod Rewrite runs before Mod Alias which would surely cause this not to work (and in truth my Alias line is in the apache conf while the rest is in .htaccess).
Is there a way to get Mod Rewrite to acknowledge the Aliased directory?
Is it possible to change the Alias line to a Rewrite line instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
-F
来代替调用子请求:Try
-F
instead to invoke a subrequest: