繁体   English   中英

Apache mod_rewrite将双斜杠转换为一个斜杠

[英]Apache mod_rewrite converts double slashes to one slash

我有这样的URL:

http://example.com/img.php?url=http://example2.com/path/to/image/name.jpg

所以我通过这个问题创建了一个规则Apache mod_rewrite复杂的URL正则表达式

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在RewriteRuleRewriteRule多个/到单个/ 请改用RewriteCond

RewriteCond %{REQUEST_URI} ^/img\.php/(.+?\.(?:jpe?g|png))$ [NC]
RewriteRule ^ img.php?url=%1 [L,QSA]

暂无
暂无

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

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