1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

$5 Contest for Mod Rewrite

Discussion in 'Design Contests' started by 45n5, Jan 21, 2007.

  1. #1
    I'll send $5 via paypal to whoever figures this out, first, and correctly. It must work on my server.

    It should be easy money for anybody familiar with mod rewrite, I just can't get it working:

    I have this URL
    I would like to rewrite it to

    I need the correct mod rewrite, or line of code for my htaccess file to make it work.

    Thanks.
     
    45n5, Jan 21, 2007 IP
  2. davidelvar

    davidelvar Well-Known Member

    Messages:
    568
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    130
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    hmm.... I don't know much about mod_rewrite. But you can check this tutorial out if it's any help.
     
    davidelvar, Jan 21, 2007 IP
  3. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    unfortuntately I've already pulled my hair out looking at tutorials so I'm not too excited about reading another.

    Hopefully the $5 entices somebody with the skills to figure it out.

    thanks dave,
     
    45n5, Jan 21, 2007 IP
  4. funzie

    funzie Well-Known Member

    Messages:
    71
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Assumming the only variable in the address is the numbers, try this

    RewriteRule ^folder/the_page-([0-9]+)[.]html$ /folder.php?whatpage=the_page-$1.html [L]
    Code (markup):
    I've only been using mod_rewrite for a week, so no guarantes.
     
    funzie, Jan 21, 2007 IP
  5. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    numbers or letter in the variable, sorry for not clarifying.

    so could also be:

    I'm going to give your work a try now and report back shortly.
     
    45n5, Jan 21, 2007 IP
  6. funzie

    funzie Well-Known Member

    Messages:
    71
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    123
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Try:

    RewriteRule ^folder/the_page-([A-Za-z0-9-]+)[.]html$ /folder.php?whatpage=the_page-$1.html [L]
    Code (markup):
     
    funzie, Jan 21, 2007 IP
    45n5 likes this.
  7. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    actually "the_page" is a variable as well. so it could also be my_pages-abc123

    I took what you had and tried to do put it all together but I get "can't find the page"

    now I get an internal 500 server error
     
    45n5, Jan 21, 2007 IP
  8. emitind

    emitind Peon

    Messages:
    567
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    This should do it. There are two variables in here ($PAGE-$NUMBER.html)

    
    RewriteEngine on
    RewriteRule ^folder/([^/]+)-([^/]+)[.]html$ folder/index.php?whatpage=$1-$2.html
    
    Code (markup):
    or in case..

    
    RewriteEngine on
    RewriteRule ^folder/([^/]+)-([^/]+)[.]html$ /folder/index.php?whatpage=$1-$2.html [L]
    
    Code (markup):
     
    emitind, Jan 21, 2007 IP
    45n5 likes this.
  9. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    emit,

    I get this error

     
    45n5, Jan 21, 2007 IP
  10. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #10
    Maybe i can help .

    " [^&]+ " can be any character or number except "&"
    tell me if it worked :)
     
    killerj, Jan 21, 2007 IP
    45n5 likes this.
  11. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #11
    Killer, I get that same error with your code

     
    45n5, Jan 21, 2007 IP
  12. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    thats wierd... its suppossed to create that static page..
     
    killerj, Jan 21, 2007 IP
  13. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #13
    i think i figured it out...
    clear browser catch and try again...
     
    killerj, Jan 21, 2007 IP
  14. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #14
    basically I just want a pretty url

    So

    site.com/folder/index.php?whatpage=something_a1-b2.html

    into

    site.com/folder/something_a1-b2.html

    my index.php file grabs the "whatpage" variable and pulls it from my DB
     
    45n5, Jan 21, 2007 IP
  15. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #15
    yep.. so why ain't it working ?
    did u try this ?
     
    killerj, Jan 21, 2007 IP
  16. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #16
    I tried it and get this

    The requested URL /folder/gateway_fx530x-t.html was not found on this server.

    I don't know why it's not working that's why I'm asking. Your code is the only th ing in the htaccess file. the site is on dreamhost. :)
     
    45n5, Jan 21, 2007 IP
  17. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #17
    gotta sleep here. no pms on this, if there is a correct answer in the morning the first right one wins.

    thanks for trying guys and girls.
     
    45n5, Jan 21, 2007 IP
  18. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #18
    do you know the code to output file as static in webpages ?
    its ok if its getting late...gnite ;)
     
    killerj, Jan 21, 2007 IP
  19. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #19
    one more thing....
    check whether the mod_rewrite module is installed .You will have to look on your phpinfo page. If you've not already created one of these for yourself, just copy and paste the following code into an new text file using text editor, save it as phpinfo.php , and upload it to your server:
    <?php phpinfo(); ?>

    Load that page up in your web browser, and perform a search for "mod_rewrite". All being well, you'll find it in the "Apache loaded modules" section of the page. If it isn't there, you'll have to contact your hosting company and politely ask them to add it to the Apache configuration.
     
    killerj, Jan 21, 2007 IP
  20. 45n5

    45n5 Peon

    Messages:
    414
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #20
    mod rewrite is enabled.
     
    45n5, Jan 22, 2007 IP