我有一个像这样的网址:
http://example.com/img.php?url=http://example2.com/path/to/image/name.jpg
所以我通过这个问题创建了一条规则Apache mod_rewrite 复杂 URL 正则表达式 https://stackoverflow.com/questions/28038590/apache-mod-rewrite-complex-url-regex
RewriteRule ^img.php\/(.+?(?:\.jpg|\.png))$ img.php?url=$1
但是当我在 htaccess 文件中使用此规则并使用相同的 URL 时,如下所示:
http://example.com/img.php/http://example2.com/path/to/image/name.jpg
结果后有双斜杠http:在我的参数中转换为一个斜杠!所以我在 php 中的第一个参数变成:
http:/example2.com/path/to/image/name.jpg
你能帮我吗?
Apache 剥离多个/
成单/
in RewriteRule
. Use RewriteCond
反而:
RewriteCond %{REQUEST_URI} ^/img\.php/(.+?\.(?:jpe?g|png))$ [NC]
RewriteRule ^ img.php?url=%1 [L,QSA]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)