Apache的mod_rewrite双斜杠转换一个斜线 [英] Apache mod_rewrite converts double slashes to one slash
本文介绍了Apache的mod_rewrite双斜杠转换一个斜线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样一个网址:
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是这样的:
but when i use this rule in htaccess file and use same URL like this:
http://example.com/img.php/http://example2.com/path/to/image/name.jpg
在结果后双斜线的 HTTP:的在我的参数转换成一个斜线!所以在PHP我的第一个参数就变成了:
in result double slashes after http: in my parameter converts to one slash! so my first parameter in php becomes:
http:/example2.com/path/to/image/name.jpg
你能帮助我吗?
推荐答案
阿帕奇剥离多个 /
进入单 /
在重写规则
。使用的RewriteCond
而不是:
Apache strips multiple /
into single /
in RewriteRule
. Use RewriteCond
instead:
RewriteCond %{REQUEST_URI} ^/img\.php/(.+?\.(?:jpe?g|png))$ [NC]
RewriteRule ^ img.php?url=%1 [L,QSA]
这篇关于Apache的mod_rewrite双斜杠转换一个斜线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文