Welcome Guest, Not a member yet? Register   Sign In
rewrite rules
#1

[eluser]ernie[/eluser]
Hello,

i'm having a hard time figuring out the following problem:
In my previous projects i used an apache rewriterule to dynamically render images with different sizes from one source image:

This is the rule:

RewriteRule ^cache/([0-9]*)_([0-9]*)_(.*)\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF) index.php/image/render/$1/$2/$4/$3 [L]

It looks in a cache folder if the requested image exists.
If it does, it returns the existing file.
If not, it redirects to a controller (Image.php) where that controller renders a new version from a source image uploaded via a CMS.
The variables in the rewrite rule are: width, height, filename, extension.
The controller looks in a folder called upload, and generates a new image according to the variables, and then it places it in the cache folder for future use.

I've used this technique in every project i've made in the past, and it works perfectly.

Now I've updated my template folder with the CI reactor version, and i keep getting the following error when i request an image from the cache folder:

"The page you requested was not found"

the request I make :
http://localhost/projectx/cache/100_10000_DSC05621.JPG

When I manually rewrite the request and paste it in the browser it works:
http://localhost/projectx/image/render/1...g/DSC05621

When i try with the rewrite-rule it doesn't, but it did in previous CI versions.

Am i missing something here? Did something change in the way request are re-routed to controller files?

TIA!
#2

[eluser]toopay[/eluser]
I would say that, these is app-design problem. You will have more flexibilty, if you wrote some Image Controller, either to handle caching nor any imaging functionality (load, upload, delete, resize etc).
#3

[eluser]ernie[/eluser]
@toopay: The image controller I talked about only handles the image generation, the rewrite-rule handles the caching part.

I've use a controller first to look if the requested image already existed but the performance is much better if I do it with the rewrite conditions

I'm just looking for the reason why the rule stopped working in the new version of CI. Is there a change in how PATH_INFO is set?
#4

[eluser]toopay[/eluser]
What cache process you talked about? Cache in server side by create some raw image, or at client side by told browser via http-header to cache your image? Both can done in controller.
#5

[eluser]ernie[/eluser]
Maybe my previous post wasn't clear:

Users can upload an image with a CMS, and it's saved automatically in a folder called upload. When i want to show a thumbnail of that image, I request the thumbnail from a folder called cache. The first time it doesn't exist, so the request is redirected to the image controller, which automatically generates the thumbnail from the original file in the upload folder and puts it in the cache folder. The controller knows the width and the height because they precede the file name in the request: ex: cache/100_75_IMG001.JPG

When I develope the website and i need 3 different sizes for one image (thumbnail, detail, zoom,...) i just need to provide the correct path and the versions get automatically generated.

This is a working example:

http://www.miniwheels.be/system/cache/500_375_A252.jpg

When you change the width and height in the filename, the images gets resized automatically
#6

[eluser]Seb[/eluser]
Just a quick question: shouldn't you have RewriteRule ^projectx/cache... instead of RewriteRule ^cache... ?
#7

[eluser]ernie[/eluser]
Not if you put the .htacces in the projectx directory

The rewrite-rule works, but not in codeigniter 2+




Theme © iAndrew 2016 - Forum software by © MyBB