Wildcard .htaccess redirect

Discussion in 'Coding Help' started by figment, Apr 22, 2011.

  1. figment

    figment New Member

  2. mneylon

    mneylon Administrator Staff Member

  3. php.allstar

    php.allstar New Member

  4. figment

    figment New Member

    Sorry guys, no joy with either solution.
     
  5. mneylon

    mneylon Administrator Staff Member

    I can probably ask one of our guys on Tuesday - he's a bit of a whiz with regular expressions + mod_rewrite ..
     
  6. Claudiu

    Claudiu New Member

    Links should help...
     
  7. php.allstar

    php.allstar New Member

    I'm surprised my above solution doesn't work. Maybe there's a conflict in your .htaccess file? Can you paste the contents of your .htaccess so I can have a look? But before you do, try this...

    RedirectMatch permanent /.* http://www.domain.com/
     
  8. figment

    figment New Member

    Thanks for all the help Guys.
    The solution that worked was:

    RewriteEngine On
    RewriteRule .* http://www.domain.com/ [R=301,L]

    PHP.Allstar for some reason removing the brackets in your solution made the difference.

    Alan
     
  9. methodshop

    methodshop New Member

    .htaccess wildcard redirect example

    i own multiple domains for my site MethodShop, including methodshop.com, methodshop.net, etc.. When doing maintenance, i'll divert traffic between the different sites so my users don't have their experience interrupted. below is the htaccess wildcard script i use. it takes whatever URL the user attempts to access and mirrors that link on another domain.

    for example,
    http://www.methodshop.net/games/play/bubblewrap/index.shtml

    would redirect to
    http://www.methodshop.com/games/play/bubblewrap/index.shtml

    here's the script....

    #htaccess script for methodshop.net
    #rewrites all methodshop.net URLs to methodshop.com

    RewriteEngine on
    RewriteRule (.*)$ http://www.methodshop.com\/$1 [R=301,L]
     

Share This Page