Redirect if url include "xxx" word // How can I do?

Discussion in 'Apache' started by horug, Aug 27, 2007.

  1. #1
    Redirect if url include "xxx" word // How can I do?

    How can I redirect xxx including url of my sites to mysite.com main domain with .htaccass?

    Thanks.
     
    horug, Aug 27, 2007 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi Horug, could you give us a little more details please.

    From what i get from what you have said, is anything with "xxx" in it should be redirected to / on your website ?

    if that's the case say so, otherwise can we get a little more info please.
     
    powerspike, Aug 27, 2007 IP
  3. horug

    horug Banned

    Messages:
    217
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Like this;

    example block word is "sex"
    abc.com/search.php?q=sex redirect -> abc.com
    abc.com/search.php?q=include+sex+search+words redirect -> abc.com
    abc.com/sex-xyz-123.html redirect -> abc.com
    abc.com/sex-xyz-123/ -> abc.com

    all links on our site include sex word redirect homepage.

    Thanks.
     
    horug, Aug 28, 2007 IP
  4. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #4
    why would you want that?
    is it just the word sex? or a list of banned words?

    if its a list of banned words your better off using php to pull them from a DB
    if not use an apache rewrite
    RewriteRule ^sex$ abc.com [R=301]
     
    m0nkeymafia, Aug 28, 2007 IP
  5. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Monkeymafia, you'll find, that rule will only redirect /sex and will causing an issue

    you'ld want something like
    
    RewriteRule sex http://abc.com [R=301,L]
    
    Code (markup):
    that should do what you are asking
     
    powerspike, Aug 28, 2007 IP
  6. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #6
    ah apologies
    nice one powerspike
     
    m0nkeymafia, Aug 29, 2007 IP
  7. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    no worries - mod rewrite can be a large pain sometimes esp when you start geting into the regex stuff =)
     
    powerspike, Aug 29, 2007 IP