1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.htaccess rewrite rule help need

Discussion in 'PHP & Perl' started by mylikes786, Aug 21, 2014.

  1. mylikes786

    mylikes786 Registered Member

    Joined:
    Oct 31, 2013
    Messages:
    80
    Likes Received:
    6
    Hello All I want know how can i rewtite text using .htaccess
    <img src "http//guio.com/1.png" width "10">
    to
    <iframe src "http//guio.com/1.png" width "25">

    In .htaccess I want set rewrite rule

    How can i do this
     
  2. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,373
    Likes Received:
    5,439
    Gender:
    Male
    Location:
    South Africa
    Home Page:
  3. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    950
    Likes Received:
    662
    Occupation:
    Web/Bot Developer
    Using jQuery you could loop through all your image tags src values using each() or map() then modify using replaceWith().
    Code:
    var src = $('img').attr('src');
    $('img').replaceWith( '<iframe src="' + src + '" width "25">' );
    

     
  4. tommyhot

    tommyhot Newbie

    Joined:
    Sep 30, 2014
    Messages:
    19
    Likes Received:
    13
    Occupation:
    Black market
    Home Page:
    Thx MrBlue, here's the code with a loop if OP finds it too "difficult" to do on his own. Just a little note, there's no need for the src variable which adds up to the memory a little.

    Code:
    $('img').each(function(){
    $(this).replaceWith( '<iframe src="' + $(this).attr('src') + '" width "25">' );
    });
     
    Last edited: Oct 2, 2014