Hello,
i am running a site consisting mainly of images . the problem im facing is high traffic loads sometimes from social networks on image links directly like : /i/image_123232.jpg instead of the image page.

I have developed teh site in a way to use same image name as teh url of image page.
For examples the image
/i/image_123456.jpg
will have page
/pic/123456

is there a possible redirect im the htaccess that i can redirect the traffic on the images to the image pages instead.

like traffic to : /i/image_12324353.jpg => /pic/12324353
Thx in advance:)

This I think: RewriteRule i/image_(\d+)\.jpg pic/$1 [L]

Hello,
Thanks alot, i tried it and a little variation but now what happens is. it is redirection the image properly to the right pages but on the page it doesn't show the image. what do u suggest further

I don't know what your page does. Perhaps you need the .jpg

Still not quite sure what your problem is. The pic/12 url shows the image and the rest of the page, but the image is still at i/image_12.jpg

If you use my rewriterule, it should not be possible to view _only_ the image in the browser.

Perhaps I misunderstood what you want to achieve.

K let me explain a bit further.
using your redirect it doesn't show the image o the image page as well.
i want the the direct image access to redirect on image page instead wehre uses can view the image ... inside teh page.
but with this rewrite rule it is redirecting direct access to page but not loading the image inside the page.
i hope that makes sense. right now i disabled your rewriterule

Makes sense now. Because the image url is also redirected to this page. You probably need to add something like this:

RewriteCond %{HTTP_REFERER} !^http://(www\.)?imgzzz.com/.*$ [NC]
RewriteRule i/image_(\d+)\.jpg pic/$1 [L]
commented: awesome help thanks +3

Right now its implemented but it doesnt redirect the to image page on directly accessing

bravo man bravo worked :D thank u so much ! let me get into it a lil more i will get back to u :)
btw it wil not affect embeding of images outside the site right ?

If you try to access the image url, you will be redirected to the page, unless the request is coming from the server itself. Hot-linking directly to the image is now NOT possible.

Btw. the redirect now only works for jpg. If you allow other formats the rule has to be changed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.