.htaccess redirect if specific words in url

Discussion in 'Apache' started by inaga, Dec 6, 2008.

  1. #1
    inaga, Dec 6, 2008 IP
  2. inaga

    inaga Active Member

    Messages:
    949
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I still need this.
     
    inaga, Dec 6, 2008 IP
  3. CommuniTriper

    CommuniTriper Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try this:

    RewriteRule (.*)one-piece(.*) http: //www.somedomain.com/ [L,R=301]

    note that i separated the http:// from the domain bcz i'm a new user and i can't post links
     
    CommuniTriper, Dec 6, 2008 IP
  4. inaga

    inaga Active Member

    Messages:
    949
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    60
    #4
    ok i got it to work thanks for the help ^_^ btw u forgot ^ and $.
     
    inaga, Dec 6, 2008 IP
  5. CommuniTriper

    CommuniTriper Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I'm quite new to apache, php and the mod_rewrite,

    I understood that you use the start of line character (^) if you want to address a matching string from the begining of the line, for example

    if you wanted all the strings that just begins with one-piece :
    ^one-piece(.*)

    or ends with one piece
    (.*)one-piece$

    anyway, glad it worked, I'm just pushing towards posting 10 messages so I can add my signature ;) (while trying to help others on the way)
     
    CommuniTriper, Dec 7, 2008 IP
  6. inaga

    inaga Active Member

    Messages:
    949
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    60
    #6
    yeah actually u need ^ at the start and $ at the end in every case so its supposed to be ^(.*)one-piece(.*)$

    it's like <?php and ?>
     
    inaga, Dec 7, 2008 IP
  7. CommuniTriper

    CommuniTriper Peon

    Messages:
    52
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    didn't know that, thanks :)
     
    CommuniTriper, Dec 7, 2008 IP