问题
i have a URL like this:
http://example.com/img.php?url=http://example2.com/path/to/image/name.jpg
so i created a rule by help of this question Apache mod_rewrite complex URL regex
RewriteRule ^img.php\/(.+?(?:\.jpg|\.png))$ img.php?url=$1
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
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
can you help me please?
回答1:
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]
来源:https://stackoverflow.com/questions/28061289/apache-mod-rewrite-converts-double-slashes-to-one-slash