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.

Simple mod rewrite help.... WILL REP! :)

Discussion in 'Apache' started by MarcL, Feb 21, 2011.

  1. #1
    http://www.yoursite.com/web.php?id=scripts

    need it to display yoursite.com/scripts

    Thanks!

    This is what I have so far but it doesnt work:
    RewriteEngine On
    RewriteRule ^(*.)$ stores.php?id=$1 [L]
    Code (markup):
     
    MarcL, Feb 21, 2011 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    Something like this might work:

    RewriteRule ^([A-Za-z0-9-]+)?$ web.php?id=$1 [L]
     
    zacharooni, Feb 23, 2011 IP
    MarcL likes this.
  3. MarcL

    MarcL Notable Member

    Messages:
    4,264
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    215
    #3
    A good try! This one doesnt give the 500 internal server error like the one I posted, but at the same time doesnt work.

    Thanks for the attempt :)
     
    MarcL, Feb 23, 2011 IP
  4. MarcL

    MarcL Notable Member

    Messages:
    4,264
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    215
    #4
    Actually that worked! I played around with it for a minute and everything is good!!!! Thanks & rep added!
     
    MarcL, Feb 23, 2011 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    It should be (I made a typo, just change the order of . and *)
    RewriteEngine On
    RewriteRule ^(.*)$ stores.php?id=$1 [L]
    Code (markup):
     
    mwasif, Feb 23, 2011 IP
  6. MarcL

    MarcL Notable Member

    Messages:
    4,264
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    215
    #6
    Unfortunately that still doesnt work...

    How would two variables work?

    RewriteRule ^([A-Za-z0-9-]+)?$/([A-Za-z0-9-]+)?$ web.php?id=$1&sec=$2 [L]
    doesnt do it...

    But RewriteRule ^([A-Za-z0-9-]+)?$ web.php?id=$1 [L] works for the one variable.
     
    MarcL, Feb 23, 2011 IP
  7. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #7
    What about this one?
    RewriteRule ^([A-Za-z0-9-]+)?(/([A-Za-z0-9-]+))?$ web.php?id=$1&sec=$3 [L]
     
    mwasif, Feb 23, 2011 IP
  8. MarcL

    MarcL Notable Member

    Messages:
    4,264
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    215
    #8
    Nope thanks for the try though...
     
    MarcL, Feb 23, 2011 IP
  9. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #9
    Alternatively you can use 2 rules to accomplish this. e.g.

    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$ web.php?id=$1&sec=$2 [L]
    RewriteRule ^([A-Za-z0-9-]+)?$ web.php?id=$1 [L]
     
    mwasif, Feb 23, 2011 IP
  10. MarcL

    MarcL Notable Member

    Messages:
    4,264
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    215
    #10
    Doesnt work :( But at the same time doesnt give a 500 internal server error...
     
    MarcL, Feb 23, 2011 IP
  11. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #11
    The code below should work for you.

    
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.*)$ web.php?id=$1 [L]
    Code (markup):


     
    RoseHosting, Feb 25, 2011 IP