HELP: how to redirect url that contains certain keywords using htaccess

Discussion in 'Programming' started by geekos, Apr 7, 2018.

  1. #1
    hi
    how to redirect url that contains certain keywords using htaccess
    ex:
    -www.website.com/keyword/ -> redirects to www.website.com
    -www.website.com/keyword1keyword2/ ->redirects to www.website.com
    Code (markup):

     
    geekos, Apr 7, 2018 IP
  2. phpmillion

    phpmillion Member

    Messages:
    145
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    45
    #2
    It depends.

    If your keyword is "static" (I mean you only want to redirect keywords that you already know), something like
    RewriteRule /keyword/ http://www.website.com
    Code (markup):
    should work.

    If you need to redirect keywords based on some rule (like keyword contains a specific letter or symbol, etc.), just use preg_match on the rule above.
     
    phpmillion, Apr 9, 2018 IP