SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    a fresh, new start... dujmovicv's Avatar
    Join Date
    Aug 2006
    Location
    Earth
    Posts
    559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect .jpg to .php

    This may sound weird but is it possible to redirect from a file.jpg to file.php?


    Full time ADMIN - art community
    Part time coder - dsign

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Hi Viktor!

    Yes, absolutely! You can match any extension in the regex of a RewriteRule and redirect as required. If you do that, however, remember that the PHP script must then send the image headers that would have been sent for the JPG file.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    a fresh, new start... dujmovicv's Avatar
    Join Date
    Aug 2006
    Location
    Earth
    Posts
    559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    Hi Viktor!

    Yes, absolutely! You can match any extension in the regex of a RewriteRule and redirect as required. If you do that, however, remember that the PHP script must then send the image headers that would have been sent for the JPG file.

    Regards,

    DK
    Hi David!

    according to that : I need to set up a mod_rewrite rule in a .htaccess which 'says' redirect ALL visits from mysite.com/images/image1.jpg to mysite.com/products.php ?

    Thank you in advance!

    Full time ADMIN - art community
    Part time coder - dsign

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Viktor,

    Not quite - it depends upon which images you want to specify and ...

    Well, to redirect ALL .jpg images to your products.php script (products? Perhaps product_images.php?) you would use RewriteRule \.jpg$ product_images.php [L]. Of course, if it's only image1.jpg, then you were fine.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •