mod_rewrite image names

Posted on 2007-10-04
Last Modified: 2012-06-22

is there a way to use mod_rewrite to change the name of my images.

for example i have <img src="/my_image_folder/imagename.gif">

but i would like <img src="/my_image_folder/anything_i_like_here_(img)_imagename.gif">

but it would still bring up the same image as above. (I put (img) in a seperator)

is there a way?


Question by:stuayre
    LVL 43

    Expert Comment

    Of course
    Put .htaccess file into my_image_folder/ (! ! !)

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !anything_you_like
    RewriteRule (.+) anything_you_like_$1 [L]

    It will rewrite any image access to anything You like, except the image have alread anytning You like in its name
    LVL 1

    Accepted Solution


    I tried it with

    <img src="/img_test/anything_i_like_here_(img)_jeep_2000.JPG">


    RewriteEngine On
    RewriteCond %{REQUEST_URI} !anything_you_like
    RewriteRule (.+) anything_you_like_$1 [L]

    in my img_test/ folder with jeep_2000.jpg but it doesnt work.

    LVL 1

    Author Closing Comment

    no answer

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
    Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now