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.

mod re-write

Discussion in 'Apache' started by bluemouse2, Jul 21, 2005.

  1. #1
    can someone help me with the last line?

    RewriteEngine on
    RewriteRule ^([0-9]+).php$ index.php?c=$1& [L]
    RewriteRule ^([0-9]+)add.php$ add_url.php?c=$1& [L]
    RewriteRule *******.php$ index.php?c=$1&s=$2 [L]

    what is instead of ***** ?
    Thanks.
     
    bluemouse2, Jul 21, 2005 IP
  2. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #2
    It totally depends on what you are trying to do, could be anything
     
    dct, Jul 21, 2005 IP
  3. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
    #3
    I want the line like this: $1-$2.php
     
    bluemouse2, Jul 21, 2005 IP
  4. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #4
    Okay try
    
    RewriteRule ^([A-Za-z0-9]+)-([A-Za-z0-9]+).php$ index.php?c=$1&s=$2 [L]
    
    Code (markup):
    This is assumming $1 and $2 can only be alpha numeric without any symbols
     
    dct, Jul 21, 2005 IP
  5. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
    #5
    Thank you!
     
    bluemouse2, Jul 21, 2005 IP
  6. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #6
    this should also work
    RewriteRule ^(.*)-(.*)$ index.php?c=$1&s=$2 [L]
    Code (markup):
     
    Dejavu, Jul 21, 2005 IP
  7. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #7
    I'm pretty new to mod_rewrite (started Monday) but with that wouldn't the . in the brackets match the hyphen between the brackets, if you know what I mean

    Your welcome, like I said I'm new to mod rewrite so still enjoy the practice, I'll get bored of it soon enough :)
     
    dct, Jul 21, 2005 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Tip: Change php to html. Search engines like that more!

    (.*) and (.*) means $1 and $2

    what ever is at $1 in the normal URL will be at the first (.*).
     
    Nintendo, Jul 21, 2005 IP
  9. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #9
    No, that will mean that the - is not in the match, and it must be (the regular expression always attempt to match the whole expression)
    consider "foo-bar"
    (.*) will match all ($1="foo-bar")
    (.*)bar will match $1="foo-", with "bar" at end, not part of $1
    similarly (.*)-(.*) will match $1=foo, $2=bar
     
    Dejavu, Jul 21, 2005 IP
    dct likes this.
  10. dct

    dct Finder of cool gadgets

    Messages:
    3,132
    Likes Received:
    328
    Best Answers:
    0
    Trophy Points:
    230
    #10
    Thanks I'm still learning and that makes perfect sense now.
     
    dct, Jul 21, 2005 IP
  11. Swordfish

    Swordfish Active Member

    Messages:
    988
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #11
    This is for biz-directory i'm assuming.. can you post your full string and what else you had to do?
     
    Swordfish, Jul 22, 2005 IP
  12. bluemouse2

    bluemouse2 Well-Known Member

    Messages:
    4,055
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    185
  13. Swordfish

    Swordfish Active Member

    Messages:
    988
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #13
    You da man. I got it working..

    This script is great. Perfect for SEO.
     
    Swordfish, Jul 22, 2005 IP