简体   繁体   English

使用get参数将htaccess规则签名从png重写为php

[英]Rewrite Rule htaccess signature from png to php with get parameter

I want to redirect signature.png?uid=1234 to signature.php?uid=1234 我想将signature.png?uid=1234重定向到signature.php?uid=1234

RewriteEngine On
RewriteBase /
RewriteRule ^signature.png\?uid=[0-9]+ signature.php?uid=$1 [L]

does not work. 不起作用。 where is my fault? 我的错在哪里?

查询字符串参数会自动传递

Redirect permanent /signature.png http://www.example.com/signature.php

You can't match against the query string (everything after the ? ) in a rewrite rule. 您无法在重写规则中与查询字符串(在?之后的所有字符)匹配。 In fact, since the query string isn't being changed at all, you don't need to match for it at all because it automatically gets appended to the end of the rewrite. 实际上,由于查询字符串根本没有更改,因此您根本不需要匹配它,因为它会自动附加到重写的末尾。 You just need to match the URI: 您只需要匹配URI:

RewriteEngine On
RewriteBase /
RewriteRule ^signature.png$ signature.php [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM