Hard to rewrite URL

Discussion in 'Apache' started by Fracisc, Mar 1, 2009.

  1. #1
    I have this URL:
    http://www.pregnancy-layouts.com/family-silhouette/pics.php?img=bunnyset&dad=yes&mom=no&pregmom=pregmom&sister=yes&sisone=no&sistwo=no&sisthree=no&sisfor=no&brother=no&broone=no&brotwo=no&brothree=no&brofor=no&familyname=Bunny%20family
    Code (markup):
    I am trying to rewrite it, so I have this in my .htaccess.
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule pics-img-(.*)-dad-(.*)-mom-(.*)-pregmom-(.*)-sister-(.*)-sisone-(.*)-sistwo-(.*)-sisthree-(.*)-sisfor-(.*)-brother-(.*)-broone-(.*)-brotwo-(.*)-brothree-(.*)-brofor-(.*)-familyname-(.*)\.htm$ pics.php?img=$1&dad=$2&mom=$3&pregmom=$4&sister=$5&sisone=$6&sistwo=$7&sisthree=$8&sisfor=$9&brother=$10&broone=$11&brotwo=$12&brothree=$13&brofor=$14&familyname=$15
    Code (markup):
    The rewritten URL should be:
    http://www.pregnancy-layouts.com/family-silhouette/pics-img-bunnyset-dad-yes-mom-no-pregmom-pregmom-sister-yes-sisone-no-sistwo-no-sisthree-no-sisfor-no-brother-no-broone-no-brotwo-no-brothree-no-brofor-no-familyname-Bunny%20family.htm 
    Code (markup):
    Now her's my problem. While the image loads up, the family name is changed. I have no idea how or why. I tried to fix it but could not find a way.
     
    Fracisc, Mar 1, 2009 IP
  2. red-x

    red-x Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this one..
    
    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)\.html$ /family-silhouette/pics.php?img=$1&dad=$2&mom=$3&pregmom=$4&sister=$5&sisone=$6&sistwo=$7&sisthree=$8&sisfor=$9&brother=$10&broone=$11&brotwo=$12&brothree=$13&brofor=$14&familyname=$15 [L]
    Code (markup):
    Hope it helps :)
     
    red-x, Mar 6, 2009 IP
  3. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,670
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #3
    @red-x: how would the URL be in your example?
     
    Fracisc, Mar 6, 2009 IP
  4. red-x

    red-x Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How you wanted it..

    http://www.pregnancy-layouts.com/family-silhouette/pics-img-bunnyset-dad-yes-mom-no-pregmom-pregmom-sister-yes-sisone-no-sistwo-no-sisthree-no-sisfor-no-brother-no-broone-no-brotwo-no-brothree-no-brofor-no-familyname-Bunny%20family.htm
    Code (markup):
     
    red-x, Mar 6, 2009 IP
  5. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,670
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #5
    Uhm.. does not working.. I have added the rewrite, tested it and it returns a 404, as you can see..
     
    Fracisc, Mar 6, 2009 IP
  6. red-x

    red-x Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try adding ^ at the beginning of your mod-rewrite code. Like..

    RewriteEngine on
    RewriteRule ^pics-img-(.*)-dad-(.*)-mom-(.*)-pregmom-(.*)-sister-(.*)-sisone-(.*)-sistwo-(.*)-sisthree-(.*)-sisfor-(.*)-brother-(.*)-broone-(.*)-brotwo-(.*)-brothree-(.*)-brofor-(.*)-familyname-(.*)\.htm$ pics.php?img=$1&dad=$2&mom=$3&pregmom=$4&sister=$5&sisone=$6&sistwo=$7&sisthree=$8&sisfor=$9&brother=$10&broone=$11&brotwo=$12&brothree=$13&brofor=$14&familyname=$15
    Code (markup):
    If that doesn't work try it with the "Options +FollowSymLinks" code on top.
     
    red-x, Mar 6, 2009 IP
  7. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,670
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #7
    OK, now it does not return a 404 but it does the same as with my first rewrite. The name is changed.. can`t figure out why..
     
    Fracisc, Mar 6, 2009 IP