htaccess redirect 301 wildcards

Discussion in 'Web Design and Development' started by design-is, Aug 16, 2010.

  1. design-is macrumors 65816

    design-is

    Joined:
    Oct 17, 2007
    Location:
    London / U.K.
    #1
    Hi all

    I'm not too hot on htaccess stuff - hoping someone can help me out.

    I want to redirect all visitors to /thispage/ when they try to get to anything below it, for example /thispage/onebelowit/

    Would it be something like:

    Code:
    Redirect 301 /thispage/* http://mysite.com/thispage/
    ?

    Cheers for any advice...

    /Doug
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    The /* in yours matches "", "/", "////", etc. The * means the character preceding either doesn't exist or occurs any number of times. In your case, the / character. The . below means any character. The + means the preceding character exists 1 or more times.

    Code:
    <IfModule mod_alias.c>
      Redirect permanent /thispage/.+ http://mysite.com/thispage/
    </IfModule>
    or
    Code:
    RewriteEngine On
    RewriteRule ^thispage/.+ /thispage/ [R=301,L]
     
  3. design-is thread starter macrumors 65816

    design-is

    Joined:
    Oct 17, 2007
    Location:
    London / U.K.

Share This Page