doushi9780 2015-03-11 23:59
浏览 385

Nginx重写将jpg解析为php

I'm converting from Apache to Nginx and I hit a tricky rewrite rule. Here is a sample link:

/cats/Parameter_1/Parameter_2.jpg

I'm matching "Paramter_1" and "Parameter_2" then ignoring the ".jpg" file extension. This worked just fine in Apache.

Here is the original Apache Rewrite rule:

RewriteRule ^cats/([-a-zA-Z0-9_]*)/([-a-zA-Z0-9_]*) /includes/cats/fan/001.php?Parameter_1=$1&Parameter_2=$2 [L]

This is the non-working Nginx rewrite that I made:

rewrite ^/cats/([-a-zA-Z0-9_]*)/([-a-zA-Z0-9_]*) /includes/cats/fan/001.php?Parameter_1=$1&Parameter_2=$2 last;

I have converted two other rewrites using this pattern. What makes this different is that the link ends in ".jpg" and I think Nginx doesn't know to parse this as a php file.

Do any of you more experienced folks have an idea how I can get this to work?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题