PageRule Unexpected Results

I have a page rule that looks like this:

http://www.domain.com/images/*/*.*

to

http://www.domain.com/images/large/$1/$2_LRG.$3

and when I submit a url that looks like this:

www.domain.com/images/2013items/painted-steel-cable-rail.jpg

It redirects me to this:

http://www.domain.com/images/large/large/large/large/large/large/large/large/large/large/large/large/large/large/large/large/2013items/painted-steel-cable-rail_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG_LRG.jpg

Huh?

There had been a RewriteRule on the hosting server, which I thought might be creating some kind of odd loop. But the behaviour is the same with that rule removed from my .htaccess file.

That’s an infinite loop because you’re rewriting * to be large, then hitting the rules again, which again catches “large” because of the wildcard. And so, and so on.

Thanks. Is there a workaround? What I ended up doing this time is redirecting the DNS away from Cloudflare and doing it with .htaccess / mod_rewrite.

Maybe add a symbolic link so you have example.com/images/rewrite pointing at example.com/images/large

So your rule would look for anything in images//.* and redirect them to images/rewrite/

That made more sense in my mind when I posted it last night.

On your server, if you create a symbolic link that the rule points to, it won’t trigger the rule:

Images really in example.com/images/WHATEVER
Symlink of example.com/img points to example.com/images

So the rule looks for anything in example.com/images and redirects it to images in example.com/img

1 Like

Thanks. I think that makes sense. So it would be a combination of a page rule on Cloudflare and symlinks on the server with the codebase on it?

Just the one symlink on the server if everything really is in /images/large

But if you’re able to get it to work without Cloudflare by using mod_rewrite, that shouldn’t change if you enable Cloudflare. It sounds like there’s something else going on.