m3tsys
m3tsys

Reputation: 3969

some mod rewrited images are not loading. why?

example.com/thumb/AWg7X9Ko5hA_default.png

for example it is working....

but

example.com/thumb/m0bt_9Qiznc_default.png

is not.. why not?

when i access

example.com/thumb/media.php?id=m0bt_9Qiznc&type=default

it works.

this is the htaccess code that i use:

RewriteEngine on
RewriteBase /
RewriteRule ^thumb/([^_]*)_([^_]*)\.png$ /thumb/script.php?id=$1&type=$2 [L]

and script.php:

$media_type = $_REQUEST['type'];
$the_id=$_REQUEST['id'];
if ($media_type=="big") 
{
header('Content-type: image/png');
readfile("http://i4.ytimg.com/vi/$the_id/0.jpg");
}
elseif ($media_type=="default") {
header('Content-type: image/png');
readfile("http://i4.ytimg.com/vi/$the_id/default.jpg"); }

Upvotes: 1

Views: 104

Answers (2)

Will Martin
Will Martin

Reputation: 4180

It's the underscores.

The regex only allows for ONE underscore, but the second file name has two underscores in it.

Upvotes: 1

mario
mario

Reputation: 145482

Your RewriteRule only allows for two parts separated by an underscore:

 RewriteRule ^thumb/([^_]*)_([^_]*)\.png$

But your URL has three:

 example.com/thumb/m0bt_9Qiznc_default.png
                     ^     ^      ^
                     1 _   2  _   3

So you probably want to change your first [^_]* into just .* for broader matches. Or use:

 RewriteRule ^thumb/([^/]+)_([^_]*)\.png$

Upvotes: 1

Related Questions