Hamid Zamani
Hamid Zamani

Reputation: 443

Apache mod_rewrite converts double slashes to one slash

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?

Upvotes: 4

Views: 1304

Answers (1)

anubhava
anubhava

Reputation: 785306

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]

Upvotes: 3

Related Questions